mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-21 16:49:10 +01:00
cleanup acceptor for AcceptOnce
This commit is contained in:
parent
4448884a3e
commit
1f76dc78d8
2 changed files with 11 additions and 7 deletions
|
@ -1091,16 +1091,18 @@ namespace stream
|
||||||
}
|
}
|
||||||
else // we must save old acceptor and set it back
|
else // we must save old acceptor and set it back
|
||||||
{
|
{
|
||||||
auto oldAcceptor = m_Acceptor;
|
m_Acceptor = std::bind (&StreamingDestination::AcceptOnceAcceptor, this,
|
||||||
m_Acceptor = [acceptor, oldAcceptor, this](std::shared_ptr<Stream> stream)
|
std::placeholders::_1, acceptor, m_Acceptor);
|
||||||
{
|
|
||||||
acceptor (stream); // m_Acceptor might be set after
|
|
||||||
m_Acceptor = oldAcceptor; // so we must restore old one before
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StreamingDestination::AcceptOnceAcceptor (std::shared_ptr<Stream> stream, Acceptor acceptor, Acceptor prev)
|
||||||
|
{
|
||||||
|
m_Acceptor = prev;
|
||||||
|
acceptor (stream);
|
||||||
|
}
|
||||||
|
|
||||||
void StreamingDestination::HandlePendingIncomingTimer (const boost::system::error_code& ecode)
|
void StreamingDestination::HandlePendingIncomingTimer (const boost::system::error_code& ecode)
|
||||||
{
|
{
|
||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
|
|
|
@ -280,7 +280,9 @@ namespace stream
|
||||||
void DeletePacket (Packet * p) { if (p) m_PacketsPool.Release (p); };
|
void DeletePacket (Packet * p) { if (p) m_PacketsPool.Release (p); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void AcceptOnceAcceptor (std::shared_ptr<Stream> stream, Acceptor acceptor, Acceptor prev);
|
||||||
|
|
||||||
void HandleNextPacket (Packet * packet);
|
void HandleNextPacket (Packet * packet);
|
||||||
std::shared_ptr<Stream> CreateNewIncomingStream ();
|
std::shared_ptr<Stream> CreateNewIncomingStream ();
|
||||||
void HandlePendingIncomingTimer (const boost::system::error_code& ecode);
|
void HandlePendingIncomingTimer (const boost::system::error_code& ecode);
|
||||||
|
|
Loading…
Add table
Reference in a new issue