mirror of https://github.com/Icinga/icinga2.git
Checker: Use weak_ptrs to keep track of services.
This commit is contained in:
parent
0e353c7b29
commit
4888a26c0e
|
@ -63,7 +63,12 @@ void CheckerComponent::CheckTimerHandler(void)
|
||||||
CheckTimeView& idx = boost::get<1>(m_IdleServices);
|
CheckTimeView& idx = boost::get<1>(m_IdleServices);
|
||||||
|
|
||||||
CheckTimeView::iterator it = idx.begin();
|
CheckTimeView::iterator it = idx.begin();
|
||||||
Service::Ptr service = *it;
|
Service::Ptr service = it->lock();
|
||||||
|
|
||||||
|
if (!service) {
|
||||||
|
idx.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (service->GetNextCheck() > now)
|
if (service->GetNextCheck() > now)
|
||||||
break;
|
break;
|
||||||
|
@ -206,8 +211,19 @@ void CheckerComponent::RescheduleCheckTimer(void)
|
||||||
typedef nth_index<ServiceSet, 1>::type CheckTimeView;
|
typedef nth_index<ServiceSet, 1>::type CheckTimeView;
|
||||||
CheckTimeView& idx = boost::get<1>(m_IdleServices);
|
CheckTimeView& idx = boost::get<1>(m_IdleServices);
|
||||||
|
|
||||||
CheckTimeView::iterator it = idx.begin();
|
Service::Ptr service;
|
||||||
Service::Ptr service = *it;
|
|
||||||
|
do {
|
||||||
|
CheckTimeView::iterator it = idx.begin();
|
||||||
|
|
||||||
|
if (it == idx.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
service = it->lock();
|
||||||
|
|
||||||
|
if (!service)
|
||||||
|
idx.erase(it);
|
||||||
|
} while (!service);
|
||||||
|
|
||||||
m_CheckTimer->Reschedule(service->GetNextCheck());
|
m_CheckTimer->Reschedule(service->GetNextCheck());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,13 @@ struct ServiceNextCheckExtractor
|
||||||
{
|
{
|
||||||
typedef double result_type;
|
typedef double result_type;
|
||||||
|
|
||||||
double operator()(const Service::Ptr& service)
|
double operator()(const Service::WeakPtr& wservice)
|
||||||
{
|
{
|
||||||
|
Service::Ptr service = wservice.lock();
|
||||||
|
|
||||||
|
if (!service)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return service->GetNextCheck();
|
return service->GetNextCheck();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -46,9 +51,9 @@ public:
|
||||||
typedef weak_ptr<CheckerComponent> WeakPtr;
|
typedef weak_ptr<CheckerComponent> WeakPtr;
|
||||||
|
|
||||||
typedef multi_index_container<
|
typedef multi_index_container<
|
||||||
Service::Ptr,
|
Service::WeakPtr,
|
||||||
indexed_by<
|
indexed_by<
|
||||||
ordered_unique<identity<Service::Ptr> >,
|
ordered_unique<identity<Service::WeakPtr> >,
|
||||||
ordered_non_unique<ServiceNextCheckExtractor>
|
ordered_non_unique<ServiceNextCheckExtractor>
|
||||||
>
|
>
|
||||||
> ServiceSet;
|
> ServiceSet;
|
||||||
|
|
Loading…
Reference in New Issue