m_DependencyCacheValid = false;
}
-ServiceStatusMessage Service::CalculateCombinedStatus(ServiceStatusMessage *input, const vector<Service>& parents)
+ServiceStatusMessage Service::CalculateCombinedStatus(Service *current, ServiceStatusMessage *input, const vector<Service>& parents)
{
vector<Service> failedServices;
time_t nextCheck = -1;
- time_t lastChange = -1;
vector<Service>::const_iterator it;
for (it = parents.begin(); it != parents.end(); it++) {
Service parent = *it;
- if (parent.GetState() != StateOK && parent.GetState() != StateWarning)
- failedServices.push_back(parent);
+ if (current && current->GetName() == parent.GetName())
+ continue;
+
+ if (!parent.HasLastCheckResult())
+ continue;
+
+ string svcname;
+ ServiceState state = StateUnknown;
+ ServiceStateType type = StateTypeHard;
+ if (input && input->GetService(&svcname) && svcname == parent.GetName()) {
+ input->GetState(&state);
+ input->GetStateType(&type);
+ } else {
+ state = parent.GetState();
+ type = parent.GetStateType();
+ }
- if (lastChange == -1 || parent.GetLastStateChange() > lastChange)
- lastChange = parent.GetLastStateChange();
+ if (state != StateOK && state != StateWarning && type == StateTypeHard)
+ failedServices.push_back(parent);
if (nextCheck == -1 || parent.GetNextCheck() < nextCheck)
nextCheck = parent.GetNextCheck();
static void UpdateDependencyCache(void);
static void InvalidateDependencyCache(void);
- static ServiceStatusMessage CalculateCombinedStatus(ServiceStatusMessage *input, const vector<Service>& parents);
+ static ServiceStatusMessage CalculateCombinedStatus(Service *current, ServiceStatusMessage *input, const vector<Service>& parents);
void SetNextCheck(time_t nextCheck);
time_t GetNextCheck(void);
vector<Service> affectedServices = child.GetParents();
affectedServices.push_back(child);
- ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(NULL, affectedServices);
+ ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&child, NULL, affectedServices);
statusmsg.SetService(child.GetName());
ServiceState state = StateUnreachable;
rm.SetMethod("delegation::ServiceStatus");
vector<Service> parents = service.GetParents();
- ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(¶ms, parents);
+ ServiceStatusMessage statusmsg = Service::CalculateCombinedStatus(&service, ¶ms, parents);
statusmsg.SetService(service.GetName());
rm.SetParams(statusmsg);