Browse Source

handle accept errors

pull/1441/head
orignal 5 years ago
parent
commit
704fca969f
  1. 12
      libi2pd/NTCP2.cpp

12
libi2pd/NTCP2.cpp

@ -1345,14 +1345,18 @@ namespace transport
{ {
conn->ServerLogin (); conn->ServerLogin ();
m_PendingIncomingSessions.push_back (conn); m_PendingIncomingSessions.push_back (conn);
conn = nullptr;
} }
} }
else else
LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ()); LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ());
} }
else
LogPrint (eLogError, "NTCP2: Accept error ", error.message ());
if (error != boost::asio::error::operation_aborted) if (error != boost::asio::error::operation_aborted)
{ {
if (!conn) // connection is used
conn = std::make_shared<NTCP2Session> (*this); conn = std::make_shared<NTCP2Session> (*this);
m_NTCP2Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAccept, this, m_NTCP2Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAccept, this,
conn, std::placeholders::_1)); conn, std::placeholders::_1));
@ -1409,13 +1413,13 @@ namespace transport
// pending // pending
for (auto it = m_PendingIncomingSessions.begin (); it != m_PendingIncomingSessions.end ();) for (auto it = m_PendingIncomingSessions.begin (); it != m_PendingIncomingSessions.end ();)
{ {
if ((*it)->IsEstablished () || (*it)->IsTerminated ()) if ((*it)->IsEstablished () || (*it)->IsTerminationTimeoutExpired (ts))
it = m_PendingIncomingSessions.erase (it); // established or terminated
else if ((*it)->IsTerminationTimeoutExpired (ts))
{ {
(*it)->Terminate (); (*it)->Terminate ();
it = m_PendingIncomingSessions.erase (it); // expired it = m_PendingIncomingSessions.erase (it); // etsablished of expired
} }
else if ((*it)->IsTerminated ())
it = m_PendingIncomingSessions.erase (it); // already terminated
else else
it++; it++;
} }

Loading…
Cancel
Save