Browse Source

fix SSU2 crash on shutdown

pull/1786/head
orignal 2 years ago
parent
commit
b574aaf99c
  1. 27
      libi2pd/SSU2.cpp

27
libi2pd/SSU2.cpp

@ -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 ();
} }
m_Sessions.clear ();
m_SessionsByRouterHash.clear ();
m_PendingOutgoingSessions.clear ();
m_Relays.clear ();
m_Introducers.clear ();
m_IntroducersV6.clear ();
if (context.SupportsV4 () || context.SupportsV6 ()) if (context.SupportsV4 () || context.SupportsV6 ())
m_ReceiveService.Stop (); m_ReceiveService.Stop ();
m_SocketV4.close (); m_SocketV4.close ();
m_SocketV6.close (); m_SocketV6.close ();
if (IsRunning ())
m_TerminationTimer.cancel ();
StopIOService (); StopIOService ();
m_Sessions.clear ();
m_SessionsByRouterHash.clear ();
m_PendingOutgoingSessions.clear ();
m_Relays.clear ();
m_Introducers.clear ();
m_IntroducersV6.clear ();
} }
void SSU2Server::SetLocalAddress (const boost::asio::ip::address& localAddress) void SSU2Server::SetLocalAddress (const boost::asio::ip::address& localAddress)

Loading…
Cancel
Save