mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
fixed race condition
This commit is contained in:
parent
5c2785cfca
commit
92eb048adb
@ -301,6 +301,7 @@ namespace tunnel
|
||||
|
||||
void Tunnels::AddTransitTunnel (TransitTunnel * tunnel)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_TransitTunnelsMutex);
|
||||
m_TransitTunnels[tunnel->GetTunnelID ()] = tunnel;
|
||||
}
|
||||
|
||||
@ -490,7 +491,10 @@ namespace tunnel
|
||||
{
|
||||
LogPrint ("Transit tunnel ", it->second->GetTunnelID (), " expired");
|
||||
auto tmp = it->second;
|
||||
it = m_TransitTunnels.erase (it);
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_TransitTunnelsMutex);
|
||||
it = m_TransitTunnels.erase (it);
|
||||
}
|
||||
delete tmp;
|
||||
}
|
||||
else
|
||||
|
1
Tunnel.h
1
Tunnel.h
@ -152,6 +152,7 @@ namespace tunnel
|
||||
std::map<uint32_t, InboundTunnel *> m_InboundTunnels;
|
||||
std::mutex m_OutboundTunnelsMutex;
|
||||
std::list<OutboundTunnel *> m_OutboundTunnels;
|
||||
std::mutex m_TransitTunnelsMutex;
|
||||
std::map<uint32_t, TransitTunnel *> m_TransitTunnels;
|
||||
std::map<i2p::data::IdentHash, TunnelPool *> m_Pools;
|
||||
TunnelPool * m_ExploratoryPool;
|
||||
|
@ -260,6 +260,8 @@ namespace tunnel
|
||||
new TunnelConfig (hops, inboundTunnel->GetTunnelConfig ()));
|
||||
tunnel->SetTunnelPool (this);
|
||||
}
|
||||
else
|
||||
LogPrint ("Can't create outbound tunnel. No inbound tunnels found");
|
||||
}
|
||||
|
||||
void TunnelPool::RecreateOutboundTunnel (OutboundTunnel * tunnel)
|
||||
@ -267,10 +269,15 @@ namespace tunnel
|
||||
InboundTunnel * inboundTunnel = GetNextInboundTunnel ();
|
||||
if (!inboundTunnel)
|
||||
inboundTunnel = tunnels.GetNextInboundTunnel ();
|
||||
LogPrint ("Re-creating destination outbound tunnel...");
|
||||
auto * newTunnel = tunnels.CreateTunnel<OutboundTunnel> (
|
||||
tunnel->GetTunnelConfig ()->Clone (inboundTunnel->GetTunnelConfig ()));
|
||||
newTunnel->SetTunnelPool (this);
|
||||
if (inboundTunnel)
|
||||
{
|
||||
LogPrint ("Re-creating destination outbound tunnel...");
|
||||
auto * newTunnel = tunnels.CreateTunnel<OutboundTunnel> (
|
||||
tunnel->GetTunnelConfig ()->Clone (inboundTunnel->GetTunnelConfig ()));
|
||||
newTunnel->SetTunnelPool (this);
|
||||
}
|
||||
else
|
||||
LogPrint ("Can't re-create outbound tunnel. No inbound tunnels found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user