From 7949ffe41e4bb945b92dc641b9ef70120e8f32b4 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 27 Feb 2015 13:07:32 -0500 Subject: [PATCH] fixed crash --- SSU.cpp | 1 + SSU.h | 2 +- SSUSession.cpp | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/SSU.cpp b/SSU.cpp index 7b5a22ff..17c76068 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -256,6 +256,7 @@ namespace transport std::shared_ptr SSUServer::FindSession (const boost::asio::ip::udp::endpoint& e) const { + std::unique_lock l(m_SessionsMutex); auto it = m_Sessions.find (e); if (it != m_Sessions.end ()) return it->second; diff --git a/SSU.h b/SSU.h index 01afe606..1b954b21 100644 --- a/SSU.h +++ b/SSU.h @@ -96,7 +96,7 @@ namespace transport boost::asio::ip::udp::socket m_Socket, m_SocketV6; boost::asio::deadline_timer m_IntroducersUpdateTimer, m_PeerTestsCleanupTimer; std::list m_Introducers; // introducers we are connected to - std::mutex m_SessionsMutex; + mutable std::mutex m_SessionsMutex; std::map > m_Sessions; std::map m_Relays; // we are introducer std::map m_PeerTests; // nonce -> creation time in milliseconds diff --git a/SSUSession.cpp b/SSUSession.cpp index 7915b65d..4fe1fc39 100644 --- a/SSUSession.cpp +++ b/SSUSession.cpp @@ -1076,7 +1076,14 @@ namespace transport uint8_t buf[48 + 18]; // encrypt message with session key FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48); - Send (buf, 48); + try + { + Send (buf, 48); + } + catch (std::exception& ex) + { + LogPrint (eLogError, "SSU send session destoriyed exception ", ex.what ()); + } LogPrint (eLogDebug, "SSU session destroyed sent"); } }