void Timer::CallExpiredTimers(void)
{
time_t now;
-
time(&now);
Timer::CollectionType::iterator prev, i;
/* adjust next call time for the check timer */
Service service = m_Services.top();
-
m_CheckTimer->Reschedule(service.GetNextCheck());
}
struct ServiceNextCheckLessComparer
{
public:
- bool operator()(const Service& a, const Service& b)
+ bool operator()(Service& a, Service& b)
{
return a.GetNextCheck() > b.GetNextCheck();
}
{
long value = 300;
GetConfigObject()->GetProperty("check_interval", &value);
+
+ if (value < 15)
+ value = 15;
+
return value;
}
GetConfigObject()->SetTag("next_check", static_cast<long>(nextCheck));
}
-time_t Service::GetNextCheck(void) const
+time_t Service::GetNextCheck(void)
{
- long value = 0;
+ long value = -1;
GetConfigObject()->GetTag("next_check", &value);
+
+ if (value == -1) {
+ value = time(NULL) + rand() % GetCheckInterval();
+ SetNextCheck(value);
+ }
+
return value;
}
long GetRetryInterval(void) const;
void SetNextCheck(time_t nextCheck);
- time_t GetNextCheck(void) const;
+ time_t GetNextCheck(void);
void SetChecker(string checker);
string GetChecker(void) const;
void SetPendingCheck(bool pending);