From abd34bdaa0434e03dbf5bc20fe74795a68a3fa53 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 21 Jun 2012 13:31:58 +0200 Subject: [PATCH] More bugfixes. --- components/delegation/delegationcomponent.cpp | 18 ++++++++++++++---- icinga/endpointmanager.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp index d5388a8c2..1417a293b 100644 --- a/components/delegation/delegationcomponent.cpp +++ b/components/delegation/delegationcomponent.cpp @@ -72,8 +72,12 @@ void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Serv void DelegationComponent::AssignServiceResponseHandler(Service& service, const Endpoint::Ptr& sender, bool timedOut) { + /* ignore the message if it's not from the designated checker for this service */ + if (!sender || service.GetChecker() != sender->GetIdentity()) + return; + if (timedOut) { - Application::Log(LogDebug, "delegation", "Service delegation for service '" + service.GetName() + "' timed out."); + Application::Log(LogInformation, "delegation", "Service delegation for service '" + service.GetName() + "' timed out."); service.SetChecker(""); } } @@ -136,6 +140,7 @@ void DelegationComponent::DelegationTimerHandler(void) std::random_shuffle(services.begin(), services.end()); + bool need_clear = false; int delegated = 0; /* re-assign services */ @@ -176,6 +181,7 @@ void DelegationComponent::DelegationTimerHandler(void) /* clear the service's current checker */ if (!checker.empty()) { + need_clear = true; service.SetChecker(""); if (oldEndpoint) @@ -202,9 +208,13 @@ void DelegationComponent::DelegationTimerHandler(void) } if (delegated > 0) { - map::iterator hit; - for (hit = histogram.begin(); hit != histogram.end(); hit++) { - ClearServices(hit->first); + // TODO: send clear message when session is established + // TODO: clear local assignments when session is lost + if (need_clear) { + map::iterator hit; + for (hit = histogram.begin(); hit != histogram.end(); hit++) { + ClearServices(hit->first); + } } for (sit = services.begin(); sit != services.end(); sit++) { diff --git a/icinga/endpointmanager.h b/icinga/endpointmanager.h index 663e48af6..82363cbec 100644 --- a/icinga/endpointmanager.h +++ b/icinga/endpointmanager.h @@ -55,7 +55,7 @@ public: void SendMulticastMessage(Endpoint::Ptr sender, const RequestMessage& message); void SendAPIMessage(const Endpoint::Ptr& sender, const Endpoint::Ptr& recipient, RequestMessage& message, - function callback, time_t timeout = 10); + function callback, time_t timeout = 30); void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message);