From c047544cdb083de9c550b5fafd34d8a83ea43ede Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 1 Oct 2014 14:32:57 -0400 Subject: [PATCH] don't block tunnel list for a long time --- Tunnel.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tunnel.cpp b/Tunnel.cpp index 346526c5..3e19549d 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -412,7 +412,6 @@ namespace tunnel { uint64_t ts = i2p::util::GetSecondsSinceEpoch (); { - std::unique_lock l(m_OutboundTunnelsMutex); for (auto it = m_OutboundTunnels.begin (); it != m_OutboundTunnels.end ();) { auto tunnel = *it; @@ -422,7 +421,10 @@ namespace tunnel auto pool = tunnel->GetTunnelPool (); if (pool) pool->TunnelExpired (tunnel); - it = m_OutboundTunnels.erase (it); + { + std::unique_lock l(m_OutboundTunnelsMutex); + it = m_OutboundTunnels.erase (it); + } delete tunnel; } else @@ -453,7 +455,6 @@ namespace tunnel { uint64_t ts = i2p::util::GetSecondsSinceEpoch (); { - std::unique_lock l(m_InboundTunnelsMutex); for (auto it = m_InboundTunnels.begin (); it != m_InboundTunnels.end ();) { auto tunnel = it->second; @@ -463,7 +464,10 @@ namespace tunnel auto pool = tunnel->GetTunnelPool (); if (pool) pool->TunnelExpired (tunnel); - it = m_InboundTunnels.erase (it); + { + std::unique_lock l(m_InboundTunnelsMutex); + it = m_InboundTunnels.erase (it); + } delete tunnel; } else