From f5f4190803bd093d6e20fcb8bea800f7ceb0e6dc Mon Sep 17 00:00:00 2001 From: R4SAS Date: Wed, 6 Feb 2019 03:03:37 +0300 Subject: [PATCH] catch error 10045 on stopping SAM acceptor (#1233), fix warning in util --- libi2pd/util.cpp | 3 ++- libi2pd_client/SAM.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libi2pd/util.cpp b/libi2pd/util.cpp index 890ace85..67366671 100644 --- a/libi2pd/util.cpp +++ b/libi2pd/util.cpp @@ -203,7 +203,9 @@ namespace net #endif if (IsWindowsXPorLater()) + { #define inet_pton inet_pton_xp + } if(localAddress.is_v4()) { @@ -220,7 +222,6 @@ namespace net LogPrint(eLogError, "NetIface: GetMTU(): address family is not supported"); return fallback; } - } #else // assume unix int GetMTUUnix(const boost::asio::ip::address& localAddress, int fallback) diff --git a/libi2pd_client/SAM.cpp b/libi2pd_client/SAM.cpp index 9fdf08aa..0dc73d72 100644 --- a/libi2pd_client/SAM.cpp +++ b/libi2pd_client/SAM.cpp @@ -963,7 +963,16 @@ namespace client void SAMBridge::Stop () { m_IsRunning = false; - m_Acceptor.cancel (); + + try + { + m_Acceptor.cancel (); + } + catch (const std::exception& ex) + { + LogPrint (eLogError, "SAM: runtime exception: ", ex.what ()); + } + for (auto& it: m_Sessions) it.second->CloseStreams (); m_Sessions.clear ();