]> granicus.if.org Git - icinga2/commitdiff
Bugfixes.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 17 Jun 2012 22:14:34 +0000 (00:14 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 17 Jun 2012 22:14:34 +0000 (00:14 +0200)
components/checker/checkercomponent.cpp
components/checker/checkercomponent.h

index cbd09176c6bfb1d01ab85bbb333efdb25009d4a6..e76989be29006c2ed10a35e0299411404d5d4f0b 100644 (file)
@@ -64,10 +64,10 @@ void CheckerComponent::CheckTimerHandler(void)
        time_t now;
        time(&now);
 
-       if (m_Services.size() == 0)
-               return;
-
        for (;;) {
+               if (m_Services.size() == 0)
+                       break;
+
                Service service = m_Services.top();
 
                if (service.GetNextCheck() > now || service.HasPendingCheck())
@@ -83,7 +83,6 @@ void CheckerComponent::CheckTimerHandler(void)
                m_PendingTasks.push_back(task);
 
                service.SetNextCheck(now + service.GetCheckInterval());
-               m_Services.push(service);
        }
 
        AdjustCheckTimer();
@@ -101,10 +100,13 @@ void CheckerComponent::ResultTimerHandler(void)
                        continue;
                }
 
-               task->GetService().SetPendingCheck(false);
+               Service service = task->GetService();
+               service.SetPendingCheck(false);
 
                CheckResult result = task->GetResult();
                Application::Log(LogInformation, "checker", "Got result! Plugin output: " + result.Output);
+
+               m_Services.push(service);
        }
 
        m_PendingTasks = unfinishedTasks;
@@ -176,6 +178,9 @@ void CheckerComponent::RevokeServiceRequestHandler(const Endpoint::Ptr& sender,
                if (service.GetName() == name)
                        continue;
 
+               if (service.HasPendingCheck()) // TODO: remember services that should be removed once their pending check is done
+                       throw runtime_error("not yet implemented");
+
                services.push_back(service);
        }
 
index da924d47c1b1c32aa857e34f110dba51760d3e0f..e33402eb135a138d4229a60c7cf7f13b8d25186c 100644 (file)
 namespace icinga
 {
 
-struct ServiceCheckPriorityLessComparer
+struct ServiceNextCheckLessComparer
 {
 public:
        bool operator()(const Service& a, const Service& b)
        {
-               if (a.HasPendingCheck() && !b.HasPendingCheck())
-                       return true;
-
                return a.GetNextCheck() > b.GetNextCheck();
        }
 };
@@ -44,16 +41,19 @@ public:
        typedef shared_ptr<CheckerComponent> Ptr;
        typedef weak_ptr<CheckerComponent> WeakPtr;
 
-       typedef priority_queue<Service, vector<Service>, ServiceCheckPriorityLessComparer> ServiceQueue;
+       typedef priority_queue<Service, vector<Service>, ServiceNextCheckLessComparer> ServiceQueue;
 
        virtual string GetName(void) const;
        virtual void Start(void);
        virtual void Stop(void);
 
 private:
+       VirtualEndpoint::Ptr m_CheckerEndpoint;
+
        ServiceQueue m_Services;
+       set<Service> m_PendingServices;
+
        Timer::Ptr m_CheckTimer;
-       VirtualEndpoint::Ptr m_CheckerEndpoint;
 
        Timer::Ptr m_ResultTimer;
        vector<CheckTask::Ptr> m_PendingTasks;