Downtime#TriggerDowntime(): ObjectLock(this), except for other Downtimes

SetRemovalInfo() and Deactivate() already lock themselves like this.
The latter calls Stop() which also runs Icinga DB hooks while being locked.
This prevents trigger and remove events from malforming each other.
Especially Downtimes don't get cancelled during triggering.
This commit is contained in:
Alexander A. Klimov 2023-11-14 12:20:14 +01:00
parent 9d44d48503
commit 7a359bb150

View File

@ -487,6 +487,8 @@ void Downtime::SetupCleanupTimer()
void Downtime::TriggerDowntime(double triggerTime)
{
ObjectLock oLock (this);
if (!CanBeTriggered())
return;
@ -499,10 +501,9 @@ void Downtime::TriggerDowntime(double triggerTime)
SetTriggerTime(triggerTime);
}
{
ObjectLock olock (this);
SetupCleanupTimer();
}
SetupCleanupTimer();
OnDowntimeTriggered(this);
oLock.Unlock();
Array::Ptr triggers = GetTriggers();
@ -517,8 +518,6 @@ void Downtime::TriggerDowntime(double triggerTime)
downtime->TriggerDowntime(triggerTime);
}
}
OnDowntimeTriggered(this);
}
void Downtime::SetRemovalInfo(const String& removedBy, double removeTime, const MessageOrigin::Ptr& origin) {