diff --git a/Tunnel.cpp b/Tunnel.cpp index 10de0a6d..18a6f811 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -290,6 +290,7 @@ namespace tunnel TunnelPool * Tunnels::CreateTunnelPool (i2p::data::LocalDestination& localDestination, int numHops) { auto pool = new TunnelPool (localDestination, numHops); + std::unique_lock l(m_PoolsMutex); m_Pools[pool->GetIdentHash ()] = pool; return pool; } @@ -298,6 +299,7 @@ namespace tunnel { if (pool) { + std::unique_lock l(m_PoolsMutex); m_Pools.erase (pool->GetIdentHash ()); delete pool; } @@ -524,6 +526,7 @@ namespace tunnel void Tunnels::ManageTunnelPools () { + std::unique_lock l(m_PoolsMutex); for (auto& it: m_Pools) { it.second->CreateTunnels (); diff --git a/Tunnel.h b/Tunnel.h index 03a74018..b62f4084 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -154,6 +154,7 @@ namespace tunnel std::list m_OutboundTunnels; std::mutex m_TransitTunnelsMutex; std::map m_TransitTunnels; + std::mutex m_PoolsMutex; std::map m_Pools; TunnelPool * m_ExploratoryPool; i2p::util::Queue m_Queue;