From 81559a7b7e0956763dd4330b9963021e9208ca65 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sat, 4 Oct 2025 13:49:55 -0500 Subject: [PATCH] safe shutdown --- .../librepertory/src/comm/packet/client_pool.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/repertory/librepertory/src/comm/packet/client_pool.cpp b/repertory/librepertory/src/comm/packet/client_pool.cpp index 3fc568b1..569dc010 100644 --- a/repertory/librepertory/src/comm/packet/client_pool.cpp +++ b/repertory/librepertory/src/comm/packet/client_pool.cpp @@ -138,14 +138,20 @@ void client_pool::pool::remove_expired() { } void client_pool::pool::shutdown() { - for (auto &entry : pool_queues_) { + std::unordered_map> pool_queues; + + unique_mutex_lock pool_lock(pool_mtx_); + std::swap(pool_queues, pool_queues_); + pool_lock.unlock(); + + for (auto &entry : pool_queues) { entry.second->shutdown = true; mutex_lock lock(entry.second->mutex); entry.second->notify.notify_all(); } - pool_queues_.clear(); + pool_queues.clear(); } client_pool::client_pool() noexcept { @@ -183,7 +189,6 @@ void client_pool::remove_client(std::string client_id) { void client_pool::remove_expired() { mutex_lock pool_lock(pool_mutex_); - for (auto &entry : pool_lookup_) { entry.second->remove_expired(); }