]> granicus.if.org Git - icinga2/commitdiff
Improve timing behavior for UpdateObjectAuthority calls
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 11 May 2016 11:04:39 +0000 (13:04 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 11 May 2016 11:04:39 +0000 (13:04 +0200)
refs #11765

lib/cli/daemoncommand.cpp
lib/remote/apilistener.cpp
lib/remote/apilistener.hpp
lib/remote/authority.cpp
lib/remote/configobjectutility.cpp

index be32b22d63b37548c745a159055735e6b8433752..5d8e6f5dde916bb3287b90d5b3ab940dcea181ac 100644 (file)
@@ -303,8 +303,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
        sigaction(SIGHUP, &sa, NULL);
 #endif /* _WIN32 */
 
-       /* update object authority */
-       ApiListener::UpdateObjectAuthorityAsync();
+       ApiListener::UpdateObjectAuthority();
 
        return Application::GetInstance()->Run();
 }
index 60498c7cc51ddbcfbaac53a8858c3259ecb81fcc..14d0cdbc6b7f906e40504608d3272830344da6fc 100644 (file)
@@ -431,6 +431,9 @@ void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoi
 
                ReplayLog(aclient);
 
+               if (endpoint->GetZone() == Zone::GetLocalZone())
+                       UpdateObjectAuthority();
+
                Log(LogInformation, "ApiListener")
                    << "Finished sending replay log for endpoint '" << endpoint->GetName() << "'.";
        } catch (const std::exception& ex) {
index d4cb5e540574160001cb85551da0c3ad0167c21e..895524f6980ba1ba727189926ec3d12165ae630e 100644 (file)
@@ -98,7 +98,7 @@ public:
        
        static Value HelloAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
 
-       static void UpdateObjectAuthorityAsync(void);
+       static void UpdateObjectAuthority(void);
 
 protected:
        virtual void OnConfigLoaded(void) override;
index cb81fa92745bce6c45e322d218ff1219479bd0a2..868ff0ebae1529a453d43054962fb4bcae215a93 100644 (file)
@@ -34,7 +34,7 @@ static bool ObjectNameLessComparer(const ConfigObject::Ptr& a, const ConfigObjec
        return a->GetName() < b->GetName();
 }
 
-static void AuthorityTimerHandler(void)
+void ApiListener::UpdateObjectAuthority(void)
 {
        Zone::Ptr my_zone = Zone::GetLocalZone();
 
@@ -80,16 +80,11 @@ static void AuthorityTimerHandler(void)
        }
 }
 
-void ApiListener::UpdateObjectAuthorityAsync(void)
-{
-       l_AuthorityTimer->Reschedule(0);
-}
-
 static void StaticInitialize(void)
 {
        l_AuthorityTimer = new Timer();
-       l_AuthorityTimer->OnTimerExpired.connect(boost::bind(&AuthorityTimerHandler));
-       l_AuthorityTimer->SetInterval(15);
+       l_AuthorityTimer->OnTimerExpired.connect(boost::bind(&ApiListener::UpdateObjectAuthority));
+       l_AuthorityTimer->SetInterval(30);
        l_AuthorityTimer->Start();
 }
 
index 0656aac799b7671b27f75aa5b8f1875891aacbf9..107caa4d1ab2bdb1de0714a10ec6791170d5d092 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "remote/configobjectutility.hpp"
 #include "remote/configpackageutility.hpp"
+#include "remote/apilistener.hpp"
 #include "config/configcompiler.hpp"
 #include "config/configitem.hpp"
 #include "base/configwriter.hpp"
@@ -149,6 +150,8 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
 
                        return false;
                }
+
+               ApiListener::UpdateObjectAuthority();
        } catch (const std::exception& ex) {
                delete expr;