fixed race condition

This commit is contained in:
orignal 2014-10-05 16:18:24 -04:00
parent f528eeae10
commit b1316dee7c

View File

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