diff --git a/Tunnel.cpp b/Tunnel.cpp index e1804be7..334abee1 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -190,7 +190,7 @@ namespace tunnel m_PendingTunnels.clear (); for (auto& it: m_Pools) - delete it; + delete it.second; m_Pools.clear (); } @@ -258,14 +258,17 @@ namespace tunnel TunnelPool * Tunnels::CreateTunnelPool (i2p::data::LocalDestination& localDestination) { auto pool = new TunnelPool (localDestination); - m_Pools.push_back (pool); + m_Pools[pool->GetIdentHash ()] = pool; return pool; } void Tunnels::DeleteTunnelPool (TunnelPool * pool) { - m_Pools.remove (pool); - delete pool; + if (pool) + { + m_Pools.erase (pool->GetIdentHash ()); + delete pool; + } } void Tunnels::AddTransitTunnel (TransitTunnel * tunnel) @@ -485,8 +488,8 @@ namespace tunnel { for (auto& it: m_Pools) { - it->CreateTunnels (); - it->TestTunnels (); + it.second->CreateTunnels (); + it.second->TestTunnels (); } } diff --git a/Tunnel.h b/Tunnel.h index d58b1ae6..7fffd64d 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -146,7 +146,7 @@ namespace tunnel std::map m_InboundTunnels; std::list m_OutboundTunnels; std::map m_TransitTunnels; - std::list m_Pools; + std::map m_Pools; i2p::util::Queue m_Queue; public: diff --git a/TunnelPool.h b/TunnelPool.h index 16061991..3a3b67b5 100644 --- a/TunnelPool.h +++ b/TunnelPool.h @@ -35,7 +35,8 @@ namespace tunnel void TunnelExpired (OutboundTunnel * expiredTunnel); std::vector GetInboundTunnels (int num) const; OutboundTunnel * GetNextOutboundTunnel (); - + const i2p::data::IdentHash& GetIdentHash () { return m_LocalDestination.GetIdentHash (); }; + void TestTunnels (); void ProcessDeliveryStatus (I2NPMessage * msg);