]> granicus.if.org Git - icinga2/commitdiff
Fix cluster config sync timestamp
authorMichael Friedrich <michael.friedrich@netways.de>
Mon, 25 Jan 2016 13:25:37 +0000 (14:25 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 25 Jan 2016 13:39:21 +0000 (14:39 +0100)
refs #11014

lib/remote/apilistener-filesync.cpp

index 883a04b26a83b8b880656186c2be125c17f56bb0..e8720b6c63fa6fcf18621250c22461a9c44db2d8 100644 (file)
@@ -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();
        }