From: Gunnar Beutner Date: Sun, 17 Jun 2012 22:14:34 +0000 (+0200) Subject: Bugfixes. X-Git-Tag: v0.0.1~406^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f64b649339077f60251eeeaebe6e0340fee56ffb;p=icinga2 Bugfixes. --- diff --git a/components/checker/checkercomponent.cpp b/components/checker/checkercomponent.cpp index cbd09176c..e76989be2 100644 --- a/components/checker/checkercomponent.cpp +++ b/components/checker/checkercomponent.cpp @@ -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); } diff --git a/components/checker/checkercomponent.h b/components/checker/checkercomponent.h index da924d47c..e33402eb1 100644 --- a/components/checker/checkercomponent.h +++ b/components/checker/checkercomponent.h @@ -23,14 +23,11 @@ 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 Ptr; typedef weak_ptr WeakPtr; - typedef priority_queue, ServiceCheckPriorityLessComparer> ServiceQueue; + typedef priority_queue, ServiceNextCheckLessComparer> ServiceQueue; virtual string GetName(void) const; virtual void Start(void); virtual void Stop(void); private: + VirtualEndpoint::Ptr m_CheckerEndpoint; + ServiceQueue m_Services; + set m_PendingServices; + Timer::Ptr m_CheckTimer; - VirtualEndpoint::Ptr m_CheckerEndpoint; Timer::Ptr m_ResultTimer; vector m_PendingTasks;