[Refactor] l_LegacyDowntimesCache: store Downtime objects, not just their names

to avoid names of vanished objects.
This commit is contained in:
Alexander A. Klimov 2024-04-24 12:33:56 +02:00
parent cb945feb19
commit 28b0f7a48c
1 changed files with 3 additions and 3 deletions

View File

@ -16,7 +16,7 @@ using namespace icinga;
static int l_NextDowntimeID = 1;
static std::mutex l_DowntimeMutex;
static std::map<int, String> l_LegacyDowntimesCache;
static std::map<int, Downtime::Ptr> l_LegacyDowntimesCache;
static Timer::Ptr l_DowntimesOrphanedTimer;
static Timer::Ptr l_DowntimesStartTimer;
@ -109,7 +109,7 @@ void Downtime::Start(bool runtimeCreated)
std::unique_lock<std::mutex> 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()