{
ServiceState old_state = GetState();
ServiceStateType old_stateType = GetStateType();
+ bool hardChange = false;
long attempt = GetCurrentCheckAttempt();
if (cr->Get("state") == StateOK) {
- if (GetState() == StateOK)
+ if (old_state != StateOK && old_stateType == StateTypeHard)
+ hardChange = true; // hard recovery
+
+ if (old_state == StateOK)
SetStateType(StateTypeHard);
attempt = 1;
if (attempt >= GetMaxCheckAttempts()) {
SetStateType(StateTypeHard);
attempt = 1;
+ hardChange = true;
} else if (GetStateType() == StateTypeSoft || GetState() == StateOK) {
SetStateType(StateTypeSoft);
attempt++;
if (GetState() != StateOK)
TriggerDowntimes();
- if (GetStateType() == StateTypeHard && (old_state != GetState() || old_stateType == StateTypeSoft)) {
+ if (hardChange) {
SetLastHardStateChange(now);
/* Make sure the notification component sees the updated