diff --git a/Destination.cpp b/Destination.cpp index 9930c72e..e7d70630 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -70,15 +70,7 @@ namespace stream StreamingDestination::~StreamingDestination () { - { - std::unique_lock l(m_StreamsMutex); - for (auto it: m_Streams) - delete it.second; - m_Streams.clear (); - } Stop (); - if (m_Pool) - i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool); delete m_LeaseSet; } @@ -95,6 +87,17 @@ namespace stream void StreamingDestination::Stop () { + { + std::unique_lock l(m_StreamsMutex); + for (auto it: m_Streams) + delete it.second; + m_Streams.clear (); + } + if (m_Pool) + { + i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool); + m_Pool = nullptr; + } m_IsRunning = false; m_Service.stop (); if (m_Thread) diff --git a/Destination.h b/Destination.h index 682cfb83..6e6a7597 100644 --- a/Destination.h +++ b/Destination.h @@ -77,6 +77,11 @@ namespace stream bool m_IsPublic; std::function m_Acceptor; + + public: + + // for HTTP only + const decltype(m_Streams)& GetStreams () const { return m_Streams; }; }; class StreamingDestinations diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 7e643177..691c5ed4 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -798,6 +798,7 @@ namespace util auto pool = dest->GetTunnelPool (); if (pool) { + s << "Tunnels:
"; for (auto it: pool->GetOutboundTunnels ()) { it->GetTunnelConfig ()->Print (s); @@ -809,6 +810,9 @@ namespace util s << "
" << std::endl; } } + s << "
Streams:
"; + for (auto it: dest->GetStreams ()) + s << it.first << "->" << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase32 () << ".b32.i2p
" << std::endl; } } diff --git a/TunnelPool.cpp b/TunnelPool.cpp index af720231..3402f9e2 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -37,6 +37,7 @@ namespace tunnel void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel) { + if (m_IsDeleted) return; { std::unique_lock l(m_InboundTunnelsMutex); m_InboundTunnels.insert (createdTunnel); @@ -60,6 +61,7 @@ namespace tunnel void TunnelPool::TunnelCreated (OutboundTunnel * createdTunnel) { + if (m_IsDeleted) return; std::unique_lock l(m_OutboundTunnelsMutex); m_OutboundTunnels.insert (createdTunnel); }