mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-22 00:59:08 +01:00
make sure all outstading data got sent before closing socket
This commit is contained in:
parent
e1d9eca7bd
commit
c45f72a63e
2 changed files with 11 additions and 4 deletions
|
@ -92,8 +92,15 @@ namespace client
|
||||||
m_Stream->Close ();
|
m_Stream->Close ();
|
||||||
m_Stream.reset ();
|
m_Stream.reset ();
|
||||||
}
|
}
|
||||||
m_Socket->close ();
|
auto s = shared_from_this ();
|
||||||
Done(shared_from_this ());
|
// make sure all outstading jobs finished before close
|
||||||
|
m_Socket->get_io_service ().post(
|
||||||
|
[s]()
|
||||||
|
{
|
||||||
|
s->m_Socket->close ();
|
||||||
|
});
|
||||||
|
|
||||||
|
Done(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PTunnelConnection::Receive ()
|
void I2PTunnelConnection::Receive ()
|
||||||
|
|
|
@ -285,7 +285,7 @@ namespace stream
|
||||||
auto s = shared_from_this();
|
auto s = shared_from_this();
|
||||||
m_Service.post ([=](void)
|
m_Service.post ([=](void)
|
||||||
{
|
{
|
||||||
if (!m_ReceiveQueue.empty () || m_Status == eStreamStatusReset || m_Status == eStreamStatusClosed)
|
if (!m_ReceiveQueue.empty () || m_Status == eStreamStatusReset)
|
||||||
s->HandleReceiveTimer (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), buffer, handler, 0);
|
s->HandleReceiveTimer (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), buffer, handler, 0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -306,7 +306,7 @@ namespace stream
|
||||||
else if (ecode == boost::asio::error::operation_aborted)
|
else if (ecode == boost::asio::error::operation_aborted)
|
||||||
{
|
{
|
||||||
// timeout not expired
|
// timeout not expired
|
||||||
if (m_Status == eStreamStatusReset || m_Status == eStreamStatusClosed)
|
if (m_Status == eStreamStatusReset)
|
||||||
handler (boost::asio::error::make_error_code (boost::asio::error::connection_reset), 0);
|
handler (boost::asio::error::make_error_code (boost::asio::error::connection_reset), 0);
|
||||||
else
|
else
|
||||||
handler (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), 0);
|
handler (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue