[icinga-checkins] icinga.org: icinga2/master: Improve timing behavior for UpdateObjectAuthority calls

git at icinga.org git at icinga.org
Tue May 17 11:44:10 CEST 2016


Module: icinga2
Branch: master
Commit: 17fa3271594b1b44bdeed2ddee2461f6d58d4742
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=17fa3271594b1b44bdeed2ddee2461f6d58d4742

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed May 11 13:04:39 2016 +0200

Improve timing behavior for UpdateObjectAuthority calls

refs #11765

---

 lib/cli/daemoncommand.cpp          |    3 +--
 lib/remote/apilistener.cpp         |    3 +++
 lib/remote/apilistener.hpp         |    2 +-
 lib/remote/authority.cpp           |   11 +++--------
 lib/remote/configobjectutility.cpp |    3 +++
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp
index be32b22..5d8e6f5 100644
--- a/lib/cli/daemoncommand.cpp
+++ b/lib/cli/daemoncommand.cpp
@@ -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();
 }
diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp
index 60498c7..14d0cdb 100644
--- a/lib/remote/apilistener.cpp
+++ b/lib/remote/apilistener.cpp
@@ -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) {
diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp
index d4cb5e5..895524f 100644
--- a/lib/remote/apilistener.hpp
+++ b/lib/remote/apilistener.hpp
@@ -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;
diff --git a/lib/remote/authority.cpp b/lib/remote/authority.cpp
index cb81fa9..868ff0e 100644
--- a/lib/remote/authority.cpp
+++ b/lib/remote/authority.cpp
@@ -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();
 }
 
diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp
index 0656aac..107caa4 100644
--- a/lib/remote/configobjectutility.cpp
+++ b/lib/remote/configobjectutility.cpp
@@ -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;
 



More information about the icinga-checkins mailing list