From cb30f0357b2bb26edbd85fcb711a391244de12ba Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 9 Feb 2021 14:24:41 +0100 Subject: [PATCH] ScheduledDowntime: consider also newly added earlier ranges --- lib/icinga/scheduleddowntime.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/icinga/scheduleddowntime.cpp b/lib/icinga/scheduleddowntime.cpp index 6642841f4..c296932b5 100644 --- a/lib/icinga/scheduleddowntime.cpp +++ b/lib/icinga/scheduleddowntime.cpp @@ -13,6 +13,7 @@ #include "base/logger.hpp" #include "base/exception.hpp" #include +#include using namespace icinga; @@ -228,28 +229,22 @@ void ScheduledDowntime::CreateNextDowntime() return; } - double minEnd = 0; + std::set ends; for (const Downtime::Ptr& downtime : GetCheckable()->GetDowntimes()) { - double end = downtime->GetEndTime(); - if (end > minEnd) - minEnd = end; - - if (downtime->GetScheduledBy() != GetName() || - downtime->GetStartTime() < Utility::GetTime()) + if (downtime->GetScheduledBy() != GetName()) continue; - /* We've found a downtime that is owned by us and that hasn't started yet - we're done. */ - return; + ends.emplace(downtime->GetEndTime()); } Log(LogDebug, "ScheduledDowntime") << "Creating new Downtime for ScheduledDowntime \"" << GetName() << "\""; - std::pair segment = FindRunningSegment(minEnd); - if (segment.first == 0 && segment.second == 0) { + std::pair segment = FindRunningSegment(); + if (segment.first == 0 && segment.second == 0 || ends.find(segment.second) != ends.end()) { segment = FindNextSegment(); - if (segment.first == 0 && segment.second == 0) + if (segment.first == 0 && segment.second == 0 || ends.find(segment.second) != ends.end()) return; }