From 47f384a0e093fb3e9b090b137bc0604565fdf412 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 17 Feb 2020 15:14:35 -0500 Subject: [PATCH] postpone SAM destination termination --- libi2pd_client/SAM.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libi2pd_client/SAM.cpp b/libi2pd_client/SAM.cpp index 138e39cf..d0942221 100644 --- a/libi2pd_client/SAM.cpp +++ b/libi2pd_client/SAM.cpp @@ -1161,6 +1161,15 @@ namespace client session->localDestination->Release (); session->localDestination->StopAcceptingStreams (); session->CloseStreams (); + if (m_IsSingleThread) + { + auto timer = std::make_shared(GetService ()); + timer->expires_from_now (boost::posix_time::seconds(5)); // postpone destination clean for 5 seconds + timer->async_wait ([timer, session](const boost::system::error_code& ecode) + { + // session's destructor is called here + }); + } } }