From 399544801497c466b9af4dc01f6decf8214f04cb Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 19 Dec 2024 14:24:26 -0500 Subject: [PATCH] fixed possible crash at shutdown --- libi2pd/Transports.cpp | 7 +++++++ libi2pd/Transports.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index 06bd724d..f3f9e5e4 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -55,6 +55,13 @@ namespace transport m_Thread->join (); m_Thread = nullptr; } + if (!m_Queue.empty ()) + { + // clean up queue + std::queue > tmp; + std::swap (m_Queue, tmp); + } + m_KeysPool.CleanUpMt (); } template diff --git a/libi2pd/Transports.h b/libi2pd/Transports.h index 85330162..c1acbb2e 100644 --- a/libi2pd/Transports.h +++ b/libi2pd/Transports.h @@ -54,8 +54,8 @@ namespace transport private: const int m_QueueSize; - std::queue > m_Queue; i2p::util::MemoryPoolMt m_KeysPool; + std::queue > m_Queue; bool m_IsRunning; std::unique_ptr m_Thread;