From: Michael Friedrich Date: Mon, 25 Jan 2016 13:25:37 +0000 (+0100) Subject: Fix cluster config sync timestamp X-Git-Tag: v2.5.0~595 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a17419e8c23af7dc236bd93f9889aada21a25114;p=icinga2 Fix cluster config sync timestamp refs #11014 --- diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 883a04b26..e8720b6c6 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -58,14 +58,15 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio { bool configChange = false; - if (oldConfig->Contains(".timestamp") && newConfig->Contains(".timestamp")) { - double oldTS = Convert::ToDouble(oldConfig->Get(".timestamp")); - double newTS = Convert::ToDouble(newConfig->Get(".timestamp")); + if (!(oldConfig->Contains(".timestamp") && newConfig->Contains(".timestamp"))) + return false; - /* skip update if our config is newer */ - if (oldTS <= newTS) - return false; - } + double oldTimestamp = Convert::ToDouble(oldConfig->Get(".timestamp")); + double newTimestamp = Convert::ToDouble(newConfig->Get(".timestamp")); + + /* skip update if our config is newer */ + if (oldTimestamp <= newTimestamp) + return false; { ObjectLock olock(newConfig); @@ -99,7 +100,7 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio String tsPath = configDir + "/.timestamp"; if (!Utility::PathExists(tsPath)) { std::ofstream fp(tsPath.CStr(), std::ofstream::out | std::ostream::trunc); - fp << std::fixed << Utility::GetTime(); + fp << std::fixed << newTimestamp; fp.close(); }