Bugfixes.

This commit is contained in:
Gunnar Beutner 2012-06-18 00:14:34 +02:00
parent 6648af73ae
commit 74bae58f21
3 changed files with 20 additions and 13 deletions

View File

@ -151,5 +151,7 @@ void Timer::Stop(void)
void Timer::Reschedule(time_t next) void Timer::Reschedule(time_t next)
{ {
m_Next = next; m_Next = next;
RescheduleTimers();
if (next < NextCall)
NextCall = next;
} }

View File

@ -64,10 +64,10 @@ void CheckerComponent::CheckTimerHandler(void)
time_t now; time_t now;
time(&now); time(&now);
if (m_Services.size() == 0)
return;
for (;;) { for (;;) {
if (m_Services.size() == 0)
break;
Service service = m_Services.top(); Service service = m_Services.top();
if (service.GetNextCheck() > now || service.HasPendingCheck()) if (service.GetNextCheck() > now || service.HasPendingCheck())
@ -83,7 +83,6 @@ void CheckerComponent::CheckTimerHandler(void)
m_PendingTasks.push_back(task); m_PendingTasks.push_back(task);
service.SetNextCheck(now + service.GetCheckInterval()); service.SetNextCheck(now + service.GetCheckInterval());
m_Services.push(service);
} }
AdjustCheckTimer(); AdjustCheckTimer();
@ -101,10 +100,13 @@ void CheckerComponent::ResultTimerHandler(void)
continue; continue;
} }
task->GetService().SetPendingCheck(false); Service service = task->GetService();
service.SetPendingCheck(false);
CheckResult result = task->GetResult(); CheckResult result = task->GetResult();
Application::Log(LogInformation, "checker", "Got result! Plugin output: " + result.Output); Application::Log(LogInformation, "checker", "Got result! Plugin output: " + result.Output);
m_Services.push(service);
} }
m_PendingTasks = unfinishedTasks; m_PendingTasks = unfinishedTasks;
@ -176,6 +178,9 @@ void CheckerComponent::RevokeServiceRequestHandler(const Endpoint::Ptr& sender,
if (service.GetName() == name) if (service.GetName() == name)
continue; 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); services.push_back(service);
} }

View File

@ -23,14 +23,11 @@
namespace icinga namespace icinga
{ {
struct ServiceCheckPriorityLessComparer struct ServiceNextCheckLessComparer
{ {
public: public:
bool operator()(const Service& a, const Service& b) bool operator()(const Service& a, const Service& b)
{ {
if (a.HasPendingCheck() && !b.HasPendingCheck())
return true;
return a.GetNextCheck() > b.GetNextCheck(); return a.GetNextCheck() > b.GetNextCheck();
} }
}; };
@ -44,17 +41,20 @@ public:
typedef shared_ptr<CheckerComponent> Ptr; typedef shared_ptr<CheckerComponent> Ptr;
typedef weak_ptr<CheckerComponent> WeakPtr; 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 string GetName(void) const;
virtual void Start(void); virtual void Start(void);
virtual void Stop(void); virtual void Stop(void);
private: private:
ServiceQueue m_Services;
Timer::Ptr m_CheckTimer;
VirtualEndpoint::Ptr m_CheckerEndpoint; VirtualEndpoint::Ptr m_CheckerEndpoint;
ServiceQueue m_Services;
set<Service> m_PendingServices;
Timer::Ptr m_CheckTimer;
Timer::Ptr m_ResultTimer; Timer::Ptr m_ResultTimer;
vector<CheckTask::Ptr> m_PendingTasks; vector<CheckTask::Ptr> m_PendingTasks;