diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-31 11:26:33 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 11:26:33 +0200 |
| commit | 9611c908cc86f61946f6b7d5d3090f4ff12c0095 (patch) | |
| tree | dac38d5a444b2551551ba2352519811fca972f94 | |
| parent | Simple file-based compute (#65) (diff) | |
| download | zen-9611c908cc86f61946f6b7d5d3090f4ff12c0095.tar.xz zen-9611c908cc86f61946f6b7d5d3090f4ff12c0095.zip | |
Fix gc shutdown stalling if shutting down while gc is running
| -rw-r--r-- | zenstore/gc.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp index 0f7a11789..3b090cae9 100644 --- a/zenstore/gc.cpp +++ b/zenstore/gc.cpp @@ -401,11 +401,16 @@ GcScheduler::Shutdown() { if (static_cast<uint32_t>(GcSchedulerStatus::kStopped) != m_Status) { - m_Status = static_cast<uint32_t>(GcSchedulerStatus::kStopped); + bool GcIsRunning = m_Status == static_cast<uint32_t>(GcSchedulerStatus::kRunning); + m_Status = static_cast<uint32_t>(GcSchedulerStatus::kStopped); m_GcSignal.notify_one(); if (m_GcThread.joinable()) { + if (GcIsRunning) + { + ZEN_INFO("Waiting for garbage collection to complete"); + } m_GcThread.join(); } } @@ -537,7 +542,11 @@ GcScheduler::SchedulerThread() ZEN_INFO("garbage collection DONE after {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs())); uint32_t RunningState = static_cast<uint32_t>(GcSchedulerStatus::kRunning); - m_Status.compare_exchange_strong(RunningState, static_cast<uint32_t>(GcSchedulerStatus::kIdle)); + if (!m_Status.compare_exchange_strong(RunningState, static_cast<uint32_t>(GcSchedulerStatus::kIdle))) + { + ZEN_ASSERT(m_Status == static_cast<uint32_t>(GcSchedulerStatus::kStopped)); + break; + } } } |