From 255c5c1459135d6a5c55f51d5ec3d15a1d9ed689 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 2 Oct 2014 12:44:11 -0400 Subject: [PATCH] fixed race condition --- Tunnel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tunnel.cpp b/Tunnel.cpp index 3e19549d..10de0a6d 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -256,6 +256,7 @@ namespace tunnel { InboundTunnel * tunnel = nullptr; size_t minReceived = 0; + std::unique_lock l(m_InboundTunnelsMutex); for (auto it : m_InboundTunnels) { if (!it.second->IsEstablished ()) continue; @@ -273,6 +274,7 @@ namespace tunnel CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); uint32_t ind = rnd.GenerateWord32 (0, m_OutboundTunnels.size () - 1), i = 0; OutboundTunnel * tunnel = nullptr; + std::unique_lock l(m_OutboundTunnelsMutex); for (auto it: m_OutboundTunnels) { if (it->IsEstablished ())