mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-24 01:46:36 +02:00
fixed race condition
This commit is contained in:
parent
482fc0e8b1
commit
f528eeae10
2 changed files with 4 additions and 0 deletions
|
@ -290,6 +290,7 @@ namespace tunnel
|
||||||
TunnelPool * Tunnels::CreateTunnelPool (i2p::data::LocalDestination& localDestination, int numHops)
|
TunnelPool * Tunnels::CreateTunnelPool (i2p::data::LocalDestination& localDestination, int numHops)
|
||||||
{
|
{
|
||||||
auto pool = new TunnelPool (localDestination, numHops);
|
auto pool = new TunnelPool (localDestination, numHops);
|
||||||
|
std::unique_lock<std::mutex> l(m_PoolsMutex);
|
||||||
m_Pools[pool->GetIdentHash ()] = pool;
|
m_Pools[pool->GetIdentHash ()] = pool;
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
@ -298,6 +299,7 @@ namespace tunnel
|
||||||
{
|
{
|
||||||
if (pool)
|
if (pool)
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_PoolsMutex);
|
||||||
m_Pools.erase (pool->GetIdentHash ());
|
m_Pools.erase (pool->GetIdentHash ());
|
||||||
delete pool;
|
delete pool;
|
||||||
}
|
}
|
||||||
|
@ -524,6 +526,7 @@ namespace tunnel
|
||||||
|
|
||||||
void Tunnels::ManageTunnelPools ()
|
void Tunnels::ManageTunnelPools ()
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_PoolsMutex);
|
||||||
for (auto& it: m_Pools)
|
for (auto& it: m_Pools)
|
||||||
{
|
{
|
||||||
it.second->CreateTunnels ();
|
it.second->CreateTunnels ();
|
||||||
|
|
1
Tunnel.h
1
Tunnel.h
|
@ -154,6 +154,7 @@ namespace tunnel
|
||||||
std::list<OutboundTunnel *> m_OutboundTunnels;
|
std::list<OutboundTunnel *> m_OutboundTunnels;
|
||||||
std::mutex m_TransitTunnelsMutex;
|
std::mutex m_TransitTunnelsMutex;
|
||||||
std::map<uint32_t, TransitTunnel *> m_TransitTunnels;
|
std::map<uint32_t, TransitTunnel *> m_TransitTunnels;
|
||||||
|
std::mutex m_PoolsMutex;
|
||||||
std::map<i2p::data::IdentHash, TunnelPool *> m_Pools;
|
std::map<i2p::data::IdentHash, TunnelPool *> m_Pools;
|
||||||
TunnelPool * m_ExploratoryPool;
|
TunnelPool * m_ExploratoryPool;
|
||||||
i2p::util::Queue<I2NPMessage> m_Queue;
|
i2p::util::Queue<I2NPMessage> m_Queue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue