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(); }