From 82afdc92c863532f4700d58c27b5cb87d9728437 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 6 Sep 2013 14:05:50 +0200 Subject: [PATCH] cluster: Ignore old messages. --- components/cluster/clustercomponent.cpp | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/components/cluster/clustercomponent.cpp b/components/cluster/clustercomponent.cpp index 0d303d643..ebc18124d 100644 --- a/components/cluster/clustercomponent.cpp +++ b/components/cluster/clustercomponent.cpp @@ -769,20 +769,28 @@ void ClusterComponent::AcknowledgementClearedHandler(const Service::Ptr& service void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Dictionary::Ptr& message) { - if (message->Contains("ts") && sender->GetRemoteLogPosition() + 10 < message->Get("ts")) { - Dictionary::Ptr lparams = boost::make_shared(); - lparams->Set("log_position", message->Get("ts")); + if (message->Contains("ts")) { + double ts = message->Get("ts"); - Dictionary::Ptr lmessage = boost::make_shared(); - lmessage->Set("jsonrpc", "2.0"); - lmessage->Set("method", "cluster::SetLogPosition"); - lmessage->Set("params", lparams); + /* ignore old messages */ + if (ts < sender->GetRemoteLogPosition()) + return; + + if (sender->GetRemoteLogPosition() + 10 < ts) { + Dictionary::Ptr lparams = boost::make_shared(); + lparams->Set("log_position", message->Get("ts")); - sender->SendMessage(lmessage); + Dictionary::Ptr lmessage = boost::make_shared(); + lmessage->Set("jsonrpc", "2.0"); + lmessage->Set("method", "cluster::SetLogPosition"); + lmessage->Set("params", lparams); - sender->SetRemoteLogPosition(message->Get("ts")); + sender->SendMessage(lmessage); - Log(LogInformation, "cluster", "Acknowledging log position for identity '" + sender->GetName() + "': " + Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", message->Get("ts"))); + sender->SetRemoteLogPosition(message->Get("ts")); + + Log(LogInformation, "cluster", "Acknowledging log position for identity '" + sender->GetName() + "': " + Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", message->Get("ts"))); + } } RelayMessage(sender, message, true); -- 2.40.0