Browse Source

fixed race condition

pull/102/head
orignal 10 years ago
parent
commit
b1316dee7c
  1. 18
      Tunnel.cpp

18
Tunnel.cpp

@ -422,9 +422,12 @@ namespace tunnel
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
{ {
LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired"); LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired");
auto pool = tunnel->GetTunnelPool (); {
if (pool) std::unique_lock<std::mutex> l(m_PoolsMutex);
pool->TunnelExpired (tunnel); auto pool = tunnel->GetTunnelPool ();
if (pool)
pool->TunnelExpired (tunnel);
}
{ {
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex); std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
it = m_OutboundTunnels.erase (it); it = m_OutboundTunnels.erase (it);
@ -465,9 +468,12 @@ namespace tunnel
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
{ {
LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired"); LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired");
auto pool = tunnel->GetTunnelPool (); {
if (pool) std::unique_lock<std::mutex> l(m_PoolsMutex);
pool->TunnelExpired (tunnel); auto pool = tunnel->GetTunnelPool ();
if (pool)
pool->TunnelExpired (tunnel);
}
{ {
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex); std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
it = m_InboundTunnels.erase (it); it = m_InboundTunnels.erase (it);

Loading…
Cancel
Save