From 75a31c79aebd77924e21ac3c0454bc8cfab214e4 Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 13 Feb 2021 18:36:23 -0500 Subject: [PATCH] don't process SSU messages after termination --- libi2pd/SSU.cpp | 13 +++++++------ libi2pd/SSU.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libi2pd/SSU.cpp b/libi2pd/SSU.cpp index 3b6280dd..79b4f35f 100644 --- a/libi2pd/SSU.cpp +++ b/libi2pd/SSU.cpp @@ -127,18 +127,18 @@ namespace transport delete m_ReceiversThread; m_ReceiversThread = nullptr; } - if (m_Thread) - { - m_Thread->join (); - delete m_Thread; - m_Thread = nullptr; - } if (m_ReceiversThreadV6) { m_ReceiversThreadV6->join (); delete m_ReceiversThreadV6; m_ReceiversThreadV6 = nullptr; } + if (m_Thread) + { + m_Thread->join (); + delete m_Thread; + m_Thread = nullptr; + } } void SSUServer::Run () @@ -377,6 +377,7 @@ namespace transport void SSUServer::HandleReceivedPackets (std::vector packets, std::map > * sessions) { + if (!m_IsRunning) return; std::shared_ptr session; for (auto& packet: packets) { diff --git a/libi2pd/SSU.h b/libi2pd/SSU.h index 213f379f..d20f1c9d 100644 --- a/libi2pd/SSU.h +++ b/libi2pd/SSU.h @@ -119,7 +119,7 @@ namespace transport }; bool m_OnlyV6; - bool m_IsRunning; + volatile bool m_IsRunning; std::thread * m_Thread, * m_ReceiversThread, * m_ReceiversThreadV6; boost::asio::io_service m_Service, m_ReceiversService, m_ReceiversServiceV6; boost::asio::io_service::work m_Work, m_ReceiversWork, m_ReceiversWorkV6;