From 28b0f7a48c042d70690dd9d8924dfa2396a9da0f Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 24 Apr 2024 12:33:56 +0200 Subject: [PATCH] [Refactor] l_LegacyDowntimesCache: store Downtime objects, not just their names to avoid names of vanished objects. --- lib/icinga/downtime.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp index 2178953f3..3ec7e01d4 100644 --- a/lib/icinga/downtime.cpp +++ b/lib/icinga/downtime.cpp @@ -16,7 +16,7 @@ using namespace icinga; static int l_NextDowntimeID = 1; static std::mutex l_DowntimeMutex; -static std::map l_LegacyDowntimesCache; +static std::map l_LegacyDowntimesCache; static Timer::Ptr l_DowntimesOrphanedTimer; static Timer::Ptr l_DowntimesStartTimer; @@ -109,7 +109,7 @@ void Downtime::Start(bool runtimeCreated) std::unique_lock lock(l_DowntimeMutex); SetLegacyId(l_NextDowntimeID); - l_LegacyDowntimesCache[l_NextDowntimeID] = GetName(); + l_LegacyDowntimesCache[l_NextDowntimeID] = this; l_NextDowntimeID++; } @@ -522,7 +522,7 @@ String Downtime::GetDowntimeIDFromLegacyID(int id) if (it == l_LegacyDowntimesCache.end()) return Empty; - return it->second; + return it->second->GetName(); } void Downtime::DowntimesStartTimerHandler()