From 2cd50ebaee55ad8abd65db080c05e3241c31b051 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 7 Jan 2022 13:39:12 -0500 Subject: [PATCH] fixed race condition --- libi2pd/TunnelPool.cpp | 4 +++- libi2pd/TunnelPool.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libi2pd/TunnelPool.cpp b/libi2pd/TunnelPool.cpp index 1551c45a..069d7da5 100644 --- a/libi2pd/TunnelPool.cpp +++ b/libi2pd/TunnelPool.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2021, The PurpleI2P Project +* Copyright (c) 2013-2022, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -338,7 +338,9 @@ namespace tunnel } // new tests + std::unique_lock l1(m_OutboundTunnelsMutex); auto it1 = m_OutboundTunnels.begin (); + std::unique_lock l2(m_InboundTunnelsMutex); auto it2 = m_InboundTunnels.begin (); while (it1 != m_OutboundTunnels.end () && it2 != m_InboundTunnels.end ()) { diff --git a/libi2pd/TunnelPool.h b/libi2pd/TunnelPool.h index 4a14ff2f..5df42279 100644 --- a/libi2pd/TunnelPool.h +++ b/libi2pd/TunnelPool.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2021, The PurpleI2P Project +* Copyright (c) 2013-2022, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -81,7 +81,6 @@ namespace tunnel std::shared_ptr GetNextInboundTunnel (std::shared_ptr excluded = nullptr, i2p::data::RouterInfo::CompatibleTransports compatible = i2p::data::RouterInfo::eAllTransports) const; std::shared_ptr GetNewOutboundTunnel (std::shared_ptr old) const; - void TestTunnels (); void ManageTunnels (uint64_t ts); void ProcessGarlicMessage (std::shared_ptr msg); void ProcessDeliveryStatus (std::shared_ptr msg); @@ -118,6 +117,7 @@ namespace tunnel private: + void TestTunnels (); void CreateInboundTunnel (); void CreateOutboundTunnel (); void CreatePairedInboundTunnel (std::shared_ptr outboundTunnel);