Refactor check scheduler some more.

This commit is contained in:
Gunnar Beutner 2013-10-18 14:10:31 +02:00
parent b517943012
commit 0c2bd2cb09
1 changed files with 8 additions and 12 deletions

View File

@ -84,12 +84,15 @@ void CheckerComponent::CheckThreadProc(void)
CheckTimeView::iterator it = idx.begin();
Service::Ptr service = *it;
if (!service->HasAuthority("checker")) {
m_IdleServices.erase(service);
continue;
}
double wait = service->GetNextCheck() - Utility::GetTime();
if (wait > 0) {
/* Make sure the service we just examined can be destroyed while we're waiting. */
service.reset();
/* Wait for the next check. */
m_CV.timed_wait(lock, boost::posix_time::milliseconds(wait * 1000));
@ -115,18 +118,11 @@ void CheckerComponent::CheckThreadProc(void)
}
}
bool authoritative = service->HasAuthority("checker");
if (!authoritative)
check = false;
/* reschedule the service if checks are disabled */
if (!check) {
if (authoritative) {
service->UpdateNextCheck();
service->UpdateNextCheck();
m_IdleServices.insert(service);
}
m_IdleServices.insert(service);
continue;
}