cluster: Prevent message loops when replaying logs.

This commit is contained in:
Gunnar Beutner 2013-09-03 10:48:34 +02:00
parent 8e381e0298
commit b97e69604d
1 changed files with 7 additions and 0 deletions

View File

@ -208,6 +208,10 @@ void ClusterComponent::RelayMessage(const Endpoint::Ptr& except, const Dictionar
Dictionary::Ptr pmessage = boost::make_shared<Dictionary>(); Dictionary::Ptr pmessage = boost::make_shared<Dictionary>();
double ts = Utility::GetTime(); double ts = Utility::GetTime();
pmessage->Set("timestamp", ts); pmessage->Set("timestamp", ts);
if (except)
pmessage->Set("except", except->GetName());
pmessage->Set("message", message); pmessage->Set("message", message);
ObjectLock olock(this); ObjectLock olock(this);
@ -320,6 +324,9 @@ void ClusterComponent::ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Pt
if (pmessage->Get("timestamp") < endpoint->GetLocalLogPosition()) if (pmessage->Get("timestamp") < endpoint->GetLocalLogPosition())
continue; continue;
if (pmessage->Get("except") == endpoint->GetName())
continue;
String json = Value(pmessage->Get("message")).Serialize(); String json = Value(pmessage->Get("message")).Serialize();
NetString::WriteStringToStream(stream, json); NetString::WriteStringToStream(stream, json);
count++; count++;