1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 12:24:19 +00:00

fix SSU2 crash on shutdown

This commit is contained in:
orignal 2022-07-26 18:46:05 -04:00
parent f9106b77bb
commit b574aaf99c

View File

@ -88,27 +88,34 @@ namespace transport
void SSU2Server::Stop () void SSU2Server::Stop ()
{ {
for (auto& it: m_Sessions) if (IsRunning ())
{
m_TerminationTimer.cancel ();
m_ResendTimer.cancel ();
m_IntroducersUpdateTimer.cancel ();
m_IntroducersUpdateTimerV6.cancel ();
}
auto sessions = m_Sessions;
for (auto& it: sessions)
{ {
it.second->RequestTermination (eSSU2TerminationReasonRouterShutdown); it.second->RequestTermination (eSSU2TerminationReasonRouterShutdown);
it.second->Done (); it.second->Done ();
} }
if (context.SupportsV4 () || context.SupportsV6 ())
m_ReceiveService.Stop ();
m_SocketV4.close ();
m_SocketV6.close ();
StopIOService ();
m_Sessions.clear (); m_Sessions.clear ();
m_SessionsByRouterHash.clear (); m_SessionsByRouterHash.clear ();
m_PendingOutgoingSessions.clear (); m_PendingOutgoingSessions.clear ();
m_Relays.clear (); m_Relays.clear ();
m_Introducers.clear (); m_Introducers.clear ();
m_IntroducersV6.clear (); m_IntroducersV6.clear ();
if (context.SupportsV4 () || context.SupportsV6 ())
m_ReceiveService.Stop ();
m_SocketV4.close ();
m_SocketV6.close ();
if (IsRunning ())
m_TerminationTimer.cancel ();
StopIOService ();
} }
void SSU2Server::SetLocalAddress (const boost::asio::ip::address& localAddress) void SSU2Server::SetLocalAddress (const boost::asio::ip::address& localAddress)