]> granicus.if.org Git - icinga2/commitdiff
cluster: Prevent message loops when replaying logs.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Sep 2013 08:48:34 +0000 (10:48 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Sep 2013 08:48:34 +0000 (10:48 +0200)
components/cluster/clustercomponent.cpp

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