]> granicus.if.org Git - icinga2/commitdiff
More bugfixes.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Jun 2012 11:31:58 +0000 (13:31 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Jun 2012 11:33:01 +0000 (13:33 +0200)
components/delegation/delegationcomponent.cpp
icinga/endpointmanager.h

index d5388a8c2b8bca181308d3153f04cf1c485540b5..1417a293b1f0e986935de7d69039942bf80997e5 100644 (file)
@@ -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<Endpoint::Ptr, int>::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<Endpoint::Ptr, int>::iterator hit;
+                       for (hit = histogram.begin(); hit != histogram.end(); hit++) {
+                               ClearServices(hit->first);
+                       }
                }
 
                for (sit = services.begin(); sit != services.end(); sit++) {
index 663e48af6d3b2f25a2ecb6b9ff76a36ff5de34f3..82363cbec7ecebff50286f4f55701b34d0dbeeee 100644 (file)
@@ -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<void(const EndpointManager::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> callback, time_t timeout = 10);
+           function<void(const EndpointManager::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> callback, time_t timeout = 30);
 
        void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message);