From 87bc291a550d90a355307904163e18713ff52113 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 17 Aug 2016 09:19:05 +0200 Subject: [PATCH] Fix that HA enabled objects are started before config validation has finished fixes #12460 --- lib/remote/apilistener.cpp | 5 +++++ lib/remote/apilistener.hpp | 1 + lib/remote/authority.cpp | 16 +--------------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 8f8c0d235..7082d9643 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -156,6 +156,11 @@ void ApiListener::Start(bool runtimeCreated) m_ReconnectTimer->Start(); m_ReconnectTimer->Reschedule(0); + m_AuthorityTimer = new Timer(); + m_AuthorityTimer->OnTimerExpired.connect(boost::bind(&ApiListener::UpdateObjectAuthority)); + m_AuthorityTimer->SetInterval(30); + m_AuthorityTimer->Start(); + OnMasterChanged(true); } diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index 49a57e181..9cb09fc31 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -116,6 +116,7 @@ private: std::set m_HttpClients; Timer::Ptr m_Timer; Timer::Ptr m_ReconnectTimer; + Timer::Ptr m_AuthorityTimer; Endpoint::Ptr m_LocalEndpoint; static ApiListener::Ptr m_Instance; diff --git a/lib/remote/authority.cpp b/lib/remote/authority.cpp index 77c4e180b..5a26090e0 100644 --- a/lib/remote/authority.cpp +++ b/lib/remote/authority.cpp @@ -21,14 +21,10 @@ #include "remote/apilistener.hpp" #include "base/configtype.hpp" #include "base/utility.hpp" -#include "base/initialize.hpp" -#include "base/timer.hpp" #include using namespace icinga; -static Timer::Ptr l_AuthorityTimer; - static bool ObjectNameLessComparer(const ConfigObject::Ptr& a, const ConfigObject::Ptr& b) { return a->GetName() < b->GetName(); @@ -70,7 +66,7 @@ void ApiListener::UpdateObjectAuthority(void) continue; BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) { - if (object->GetHAMode() != HARunOnce) + if (!object->IsActive() || object->GetHAMode() != HARunOnce) continue; bool authority; @@ -84,13 +80,3 @@ void ApiListener::UpdateObjectAuthority(void) } } } - -static void StaticInitialize(void) -{ - l_AuthorityTimer = new Timer(); - l_AuthorityTimer->OnTimerExpired.connect(boost::bind(&ApiListener::UpdateObjectAuthority)); - l_AuthorityTimer->SetInterval(30); - l_AuthorityTimer->Start(); -} - -INITIALIZE_ONCE(StaticInitialize); -- 2.40.0