From 9a617297f2e69a0ee68acda04f40547aa9fae9fc Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 3 Oct 2014 22:46:20 -0400 Subject: [PATCH] operation_aborted error code for stream --- SAM.cpp | 7 ++++--- Streaming.h | 9 ++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/SAM.cpp b/SAM.cpp index 458f7a12..9b423ff8 100644 --- a/SAM.cpp +++ b/SAM.cpp @@ -251,7 +251,7 @@ namespace stream Connect (*leaseSet, session); else { - i2p::data::netdb.Subscribe (dest.GetIdentHash (), session->localDestination->GetTunnelPool ()); + i2p::data::netdb.RequestDestination (dest.GetIdentHash (), true, session->localDestination->GetTunnelPool ()); m_Timer.expires_from_now (boost::posix_time::seconds(SAM_CONNECT_TIMEOUT)); m_Timer.async_wait (boost::bind (&SAMSocket::HandleStreamDestinationRequestTimer, this, boost::asio::placeholders::error, dest.GetIdentHash (), session)); @@ -366,7 +366,7 @@ namespace stream SendNamingLookupReply (leaseSet); else { - i2p::data::netdb.Subscribe (ident, m_Session->localDestination->GetTunnelPool ()); + i2p::data::netdb.RequestDestination (ident, true, m_Session->localDestination->GetTunnelPool ()); m_Timer.expires_from_now (boost::posix_time::seconds(SAM_NAMING_LOOKUP_TIMEOUT)); m_Timer.async_wait (boost::bind (&SAMSocket::HandleNamingLookupDestinationRequestTimer, this, boost::asio::placeholders::error, ident)); @@ -447,7 +447,8 @@ namespace stream if (ecode) { LogPrint ("SAM stream read error: ", ecode.message ()); - Terminate (); + if (ecode != boost::asio::error::operation_aborted) + Terminate (); } else { diff --git a/Streaming.h b/Streaming.h index ba22fb5f..fc29e735 100644 --- a/Streaming.h +++ b/Streaming.h @@ -275,8 +275,15 @@ namespace stream { size_t received = ConcatenatePackets (boost::asio::buffer_cast(buffer), boost::asio::buffer_size(buffer)); if (ecode == boost::asio::error::operation_aborted) + { // timeout not expired - handler (boost::system::error_code (), received); + if (m_IsOpen) + // no error + handler (boost::system::error_code (), received); + else + // socket closed + handler (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), 0); + } else // timeout expired handler (boost::asio::error::make_error_code (boost::asio::error::timed_out), received);