From b3e08b2cf462ec9b0761c8aad9d8a7fc48bed5cb Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 27 Jan 2015 14:55:46 -0500 Subject: [PATCH] shared_ptr for tunnels --- Destination.cpp | 2 +- Garlic.cpp | 2 +- NetDb.cpp | 2 +- NetDb.h | 2 +- Streaming.cpp | 7 +++--- Streaming.h | 2 +- Tunnel.cpp | 57 ++++++++++++++++--------------------------------- Tunnel.h | 32 +++++++++++++-------------- TunnelBase.h | 3 ++- TunnelPool.cpp | 36 +++++++++++++++---------------- TunnelPool.h | 24 ++++++++++----------- 11 files changed, 74 insertions(+), 95 deletions(-) diff --git a/Destination.cpp b/Destination.cpp index 8d5d59bb..edf8bc6f 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -510,7 +510,7 @@ namespace client I2NPMessage * msg = WrapMessage (*nextFloodfill, CreateLeaseSetDatabaseLookupMsg (dest, request->excluded, - replyTunnel, replyKey, replyTag)); + replyTunnel.get (), replyKey, replyTag)); outboundTunnel->SendTunnelDataMsg ( { i2p::tunnel::TunnelMessageBlock diff --git a/Garlic.cpp b/Garlic.cpp index a4ca69cd..6b2dc700 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -475,7 +475,7 @@ namespace garlic buf += 32; uint32_t gwTunnel = bufbe32toh (buf); buf += 4; - i2p::tunnel::OutboundTunnel * tunnel = nullptr; + std::shared_ptr tunnel; if (from && from->GetTunnelPool ()) tunnel = from->GetTunnelPool ()->GetNextOutboundTunnel (); if (tunnel) // we have send it through an outbound tunnel diff --git a/NetDb.cpp b/NetDb.cpp index 3783bcbd..ec3fa113 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -22,7 +22,7 @@ namespace i2p namespace data { I2NPMessage * RequestedDestination::CreateRequestMessage (std::shared_ptr router, - const i2p::tunnel::InboundTunnel * replyTunnel) + std::shared_ptr replyTunnel) { I2NPMessage * msg = i2p::CreateRouterInfoDatabaseLookupMsg (m_Destination, replyTunnel->GetNextIdentHash (), replyTunnel->GetNextTunnelID (), m_IsExploratory, diff --git a/NetDb.h b/NetDb.h index f2e20661..dfa7c7fb 100644 --- a/NetDb.h +++ b/NetDb.h @@ -38,7 +38,7 @@ namespace data bool IsExploratory () const { return m_IsExploratory; }; bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); }; uint64_t GetCreationTime () const { return m_CreationTime; }; - I2NPMessage * CreateRequestMessage (std::shared_ptr, const i2p::tunnel::InboundTunnel * replyTunnel); + I2NPMessage * CreateRequestMessage (std::shared_ptr, std::shared_ptr replyTunnel); I2NPMessage * CreateRequestMessage (const IdentHash& floodfill); void SetRequestComplete (const RequestComplete& requestComplete) { m_RequestComplete = requestComplete; }; diff --git a/Streaming.cpp b/Streaming.cpp index 74807cae..bd6bac48 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -15,8 +15,8 @@ namespace stream std::shared_ptr remote, int port): m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_IsOpen (false), m_IsReset (false), m_IsAckSendScheduled (false), m_LocalDestination (local), - m_RemoteLeaseSet (remote), m_CurrentOutboundTunnel (nullptr), - m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), m_AckSendTimer (m_Service), + m_RemoteLeaseSet (remote), m_ReceiveTimer (m_Service), + m_ResendTimer (m_Service), m_AckSendTimer (m_Service), m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (port) { m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); @@ -26,8 +26,7 @@ namespace stream Stream::Stream (boost::asio::io_service& service, StreamingDestination& local): m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_IsOpen (false), m_IsReset (false), m_IsAckSendScheduled (false), m_LocalDestination (local), - m_CurrentOutboundTunnel (nullptr), m_ReceiveTimer (m_Service), - m_ResendTimer (m_Service), m_AckSendTimer (m_Service), + m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), m_AckSendTimer (m_Service), m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (0) { m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); diff --git a/Streaming.h b/Streaming.h index 76c0f73d..62452e6b 100644 --- a/Streaming.h +++ b/Streaming.h @@ -147,7 +147,7 @@ namespace stream std::shared_ptr m_RemoteLeaseSet; std::shared_ptr m_RoutingSession; i2p::data::Lease m_CurrentRemoteLease; - i2p::tunnel::OutboundTunnel * m_CurrentOutboundTunnel; + std::shared_ptr m_CurrentOutboundTunnel; std::queue m_ReceiveQueue; std::set m_SavedPackets; std::set m_SentPackets; diff --git a/Tunnel.cpp b/Tunnel.cpp index 75259ba5..fe983ae1 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -27,7 +27,7 @@ namespace tunnel delete m_Config; } - void Tunnel::Build (uint32_t replyMsgID, OutboundTunnel * outboundTunnel) + void Tunnel::Build (uint32_t replyMsgID, std::shared_ptr outboundTunnel) { CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); auto numHops = m_Config->GetNumHops (); @@ -209,29 +209,12 @@ namespace tunnel Tunnels::~Tunnels () { - for (auto& it : m_OutboundTunnels) - delete it; - m_OutboundTunnels.clear (); - - for (auto& it : m_InboundTunnels) - delete it.second; - m_InboundTunnels.clear (); - for (auto& it : m_TransitTunnels) delete it.second; m_TransitTunnels.clear (); - - ManagePendingTunnels (); - for (auto& it : m_PendingInboundTunnels) - delete it.second; - m_PendingInboundTunnels.clear (); - - for (auto& it : m_PendingOutboundTunnels) - delete it.second; - m_PendingOutboundTunnels.clear (); } - InboundTunnel * Tunnels::GetInboundTunnel (uint32_t tunnelID) + std::shared_ptr Tunnels::GetInboundTunnel (uint32_t tunnelID) { auto it = m_InboundTunnels.find(tunnelID); if (it != m_InboundTunnels.end ()) @@ -247,18 +230,18 @@ namespace tunnel return nullptr; } - InboundTunnel * Tunnels::GetPendingInboundTunnel (uint32_t replyMsgID) + std::shared_ptr Tunnels::GetPendingInboundTunnel (uint32_t replyMsgID) { return GetPendingTunnel (replyMsgID, m_PendingInboundTunnels); } - OutboundTunnel * Tunnels::GetPendingOutboundTunnel (uint32_t replyMsgID) + std::shared_ptr Tunnels::GetPendingOutboundTunnel (uint32_t replyMsgID) { return GetPendingTunnel (replyMsgID, m_PendingOutboundTunnels); } template - TTunnel * Tunnels::GetPendingTunnel (uint32_t replyMsgID, const std::map& pendingTunnels) + std::shared_ptr Tunnels::GetPendingTunnel (uint32_t replyMsgID, const std::map >& pendingTunnels) { auto it = pendingTunnels.find(replyMsgID); if (it != pendingTunnels.end () && it->second->GetState () == eTunnelStatePending) @@ -269,9 +252,9 @@ namespace tunnel return nullptr; } - InboundTunnel * Tunnels::GetNextInboundTunnel () + std::shared_ptr Tunnels::GetNextInboundTunnel () { - InboundTunnel * tunnel = nullptr; + std::shared_ptr tunnel; size_t minReceived = 0; for (auto it : m_InboundTunnels) { @@ -285,11 +268,11 @@ namespace tunnel return tunnel; } - OutboundTunnel * Tunnels::GetNextOutboundTunnel () + std::shared_ptr Tunnels::GetNextOutboundTunnel () { CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); uint32_t ind = rnd.GenerateWord32 (0, m_OutboundTunnels.size () - 1), i = 0; - OutboundTunnel * tunnel = nullptr; + std::shared_ptr tunnel; for (auto it: m_OutboundTunnels) { if (it->IsEstablished ()) @@ -384,7 +367,7 @@ namespace tunnel prevTunnel->FlushTunnelDataMsgs (); if (!tunnel && typeID == eI2NPTunnelData) - tunnel = GetInboundTunnel (tunnelID); + tunnel = GetInboundTunnel (tunnelID).get (); if (!tunnel) tunnel = GetTransitTunnel (tunnelID); if (tunnel) @@ -499,7 +482,6 @@ namespace tunnel if (ts > tunnel->GetCreationTime () + TUNNEL_CREATION_TIMEOUT) { LogPrint ("Pending tunnel build request ", it->first, " timeout. Deleted"); - delete tunnel; it = pendingTunnels.erase (it); } else @@ -507,11 +489,10 @@ namespace tunnel break; case eTunnelStateBuildFailed: LogPrint ("Pending tunnel build request ", it->first, " failed. Deleted"); - delete tunnel; it = pendingTunnels.erase (it); break; case eTunnelStateBuildReplyReceived: - // intermidiate state, will be either established of build failed + // intermediate state, will be either established of build failed it++; break; default: @@ -536,7 +517,6 @@ namespace tunnel pool->TunnelExpired (tunnel); } it = m_OutboundTunnels.erase (it); - delete tunnel; } else { @@ -550,7 +530,7 @@ namespace tunnel if (m_OutboundTunnels.size () < 5) { // trying to create one more oubound tunnel - InboundTunnel * inboundTunnel = GetNextInboundTunnel (); + auto inboundTunnel = GetNextInboundTunnel (); if (!inboundTunnel) return; LogPrint ("Creating one hop outbound tunnel..."); CreateTunnel ( @@ -578,7 +558,6 @@ namespace tunnel pool->TunnelExpired (tunnel); } it = m_InboundTunnels.erase (it); - delete tunnel; } else { @@ -655,26 +634,26 @@ namespace tunnel } template - TTunnel * Tunnels::CreateTunnel (TunnelConfig * config, OutboundTunnel * outboundTunnel) + std::shared_ptr Tunnels::CreateTunnel (TunnelConfig * config, std::shared_ptr outboundTunnel) { - TTunnel * newTunnel = new TTunnel (config); + auto newTunnel = std::make_shared (config); uint32_t replyMsgID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); AddPendingTunnel (replyMsgID, newTunnel); newTunnel->Build (replyMsgID, outboundTunnel); return newTunnel; } - void Tunnels::AddPendingTunnel (uint32_t replyMsgID, InboundTunnel * tunnel) + void Tunnels::AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr tunnel) { m_PendingInboundTunnels[replyMsgID] = tunnel; } - void Tunnels::AddPendingTunnel (uint32_t replyMsgID, OutboundTunnel * tunnel) + void Tunnels::AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr tunnel) { m_PendingOutboundTunnels[replyMsgID] = tunnel; } - void Tunnels::AddOutboundTunnel (OutboundTunnel * newTunnel) + void Tunnels::AddOutboundTunnel (std::shared_ptr newTunnel) { m_OutboundTunnels.push_back (newTunnel); auto pool = newTunnel->GetTunnelPool (); @@ -684,7 +663,7 @@ namespace tunnel newTunnel->SetTunnelPool (nullptr); } - void Tunnels::AddInboundTunnel (InboundTunnel * newTunnel) + void Tunnels::AddInboundTunnel (std::shared_ptr newTunnel) { m_InboundTunnels[newTunnel->GetTunnelID ()] = newTunnel; auto pool = newTunnel->GetTunnelPool (); diff --git a/Tunnel.h b/Tunnel.h index 892f7430..db29b52a 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -47,7 +47,7 @@ namespace tunnel Tunnel (TunnelConfig * config); ~Tunnel (); - void Build (uint32_t replyMsgID, OutboundTunnel * outboundTunnel = 0); + void Build (uint32_t replyMsgID, std::shared_ptr outboundTunnel = nullptr); TunnelConfig * GetTunnelConfig () const { return m_Config; } TunnelState GetState () const { return m_State; }; @@ -120,23 +120,23 @@ namespace tunnel void Start (); void Stop (); - InboundTunnel * GetInboundTunnel (uint32_t tunnelID); - InboundTunnel * GetPendingInboundTunnel (uint32_t replyMsgID); - OutboundTunnel * GetPendingOutboundTunnel (uint32_t replyMsgID); - InboundTunnel * GetNextInboundTunnel (); - OutboundTunnel * GetNextOutboundTunnel (); + std::shared_ptr GetInboundTunnel (uint32_t tunnelID); + std::shared_ptr GetPendingInboundTunnel (uint32_t replyMsgID); + std::shared_ptr GetPendingOutboundTunnel (uint32_t replyMsgID); + std::shared_ptr GetNextInboundTunnel (); + std::shared_ptr GetNextOutboundTunnel (); std::shared_ptr GetExploratoryPool () const { return m_ExploratoryPool; }; TransitTunnel * GetTransitTunnel (uint32_t tunnelID); int GetTransitTunnelsExpirationTimeout (); void AddTransitTunnel (TransitTunnel * tunnel); - void AddOutboundTunnel (OutboundTunnel * newTunnel); - void AddInboundTunnel (InboundTunnel * newTunnel); + void AddOutboundTunnel (std::shared_ptr newTunnel); + void AddInboundTunnel (std::shared_ptr newTunnel); void PostTunnelData (I2NPMessage * msg); void PostTunnelData (const std::vector& msgs); template - TTunnel * CreateTunnel (TunnelConfig * config, OutboundTunnel * outboundTunnel = 0); - void AddPendingTunnel (uint32_t replyMsgID, InboundTunnel * tunnel); - void AddPendingTunnel (uint32_t replyMsgID, OutboundTunnel * tunnel); + std::shared_ptr CreateTunnel (TunnelConfig * config, std::shared_ptr outboundTunnel = nullptr); + void AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr tunnel); + void AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr tunnel); std::shared_ptr CreateTunnelPool (i2p::garlic::GarlicDestination * localDestination, int numInboundHops, int numOuboundHops); void DeleteTunnelPool (std::shared_ptr pool); void StopTunnelPool (std::shared_ptr pool); @@ -144,7 +144,7 @@ namespace tunnel private: template - TTunnel * GetPendingTunnel (uint32_t replyMsgID, const std::map& pendingTunnels); + std::shared_ptr GetPendingTunnel (uint32_t replyMsgID, const std::map >& pendingTunnels); void HandleTunnelGatewayMsg (TunnelBase * tunnel, I2NPMessage * msg); @@ -164,10 +164,10 @@ namespace tunnel bool m_IsRunning; std::thread * m_Thread; - std::map m_PendingInboundTunnels; // by replyMsgID - std::map m_PendingOutboundTunnels; // by replyMsgID - std::map m_InboundTunnels; - std::list m_OutboundTunnels; + std::map > m_PendingInboundTunnels; // by replyMsgID + std::map > m_PendingOutboundTunnels; // by replyMsgID + std::map > m_InboundTunnels; + std::list > m_OutboundTunnels; std::mutex m_TransitTunnelsMutex; std::map m_TransitTunnels; std::mutex m_PoolsMutex; diff --git a/TunnelBase.h b/TunnelBase.h index dbb9c361..d867bf9a 100644 --- a/TunnelBase.h +++ b/TunnelBase.h @@ -2,6 +2,7 @@ #define TUNNEL_BASE_H__ #include +#include #include "Timestamp.h" #include "I2NPProtocol.h" #include "Identity.h" @@ -54,7 +55,7 @@ namespace tunnel struct TunnelCreationTimeCmp { - bool operator() (const TunnelBase * t1, const TunnelBase * t2) const + bool operator() (std::shared_ptr t1, std::shared_ptr t2) const { if (t1->GetCreationTime () != t2->GetCreationTime ()) return t1->GetCreationTime () > t2->GetCreationTime (); diff --git a/TunnelPool.cpp b/TunnelPool.cpp index 2482d670..1445ee99 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -38,7 +38,7 @@ namespace tunnel m_Tests.clear (); } - void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel) + void TunnelPool::TunnelCreated (std::shared_ptr createdTunnel) { if (!m_IsActive) return; { @@ -49,7 +49,7 @@ namespace tunnel m_LocalDestination->SetLeaseSetUpdated (); } - void TunnelPool::TunnelExpired (InboundTunnel * expiredTunnel) + void TunnelPool::TunnelExpired (std::shared_ptr expiredTunnel) { if (expiredTunnel) { @@ -63,14 +63,14 @@ namespace tunnel } } - void TunnelPool::TunnelCreated (OutboundTunnel * createdTunnel) + void TunnelPool::TunnelCreated (std::shared_ptr createdTunnel) { if (!m_IsActive) return; std::unique_lock l(m_OutboundTunnelsMutex); m_OutboundTunnels.insert (createdTunnel); } - void TunnelPool::TunnelExpired (OutboundTunnel * expiredTunnel) + void TunnelPool::TunnelExpired (std::shared_ptr expiredTunnel) { if (expiredTunnel) { @@ -84,9 +84,9 @@ namespace tunnel } } - std::vector TunnelPool::GetInboundTunnels (int num) const + std::vector > TunnelPool::GetInboundTunnels (int num) const { - std::vector v; + std::vector > v; int i = 0; std::unique_lock l(m_InboundTunnelsMutex); for (auto it : m_InboundTunnels) @@ -101,13 +101,13 @@ namespace tunnel return v; } - OutboundTunnel * TunnelPool::GetNextOutboundTunnel (OutboundTunnel * suggested) const + std::shared_ptr TunnelPool::GetNextOutboundTunnel (std::shared_ptr suggested) const { std::unique_lock l(m_OutboundTunnelsMutex); return GetNextTunnel (m_OutboundTunnels, suggested); } - InboundTunnel * TunnelPool::GetNextInboundTunnel (InboundTunnel * suggested) const + std::shared_ptr TunnelPool::GetNextInboundTunnel (std::shared_ptr suggested) const { std::unique_lock l(m_InboundTunnelsMutex); return GetNextTunnel (m_InboundTunnels, suggested); @@ -274,7 +274,7 @@ namespace tunnel void TunnelPool::CreateInboundTunnel () { - OutboundTunnel * outboundTunnel = GetNextOutboundTunnel (); + auto outboundTunnel = GetNextOutboundTunnel (); if (!outboundTunnel) outboundTunnel = tunnels.GetNextOutboundTunnel (); LogPrint ("Creating destination inbound tunnel..."); @@ -299,23 +299,23 @@ namespace tunnel hops.push_back (hop); } std::reverse (hops.begin (), hops.end ()); - auto * tunnel = tunnels.CreateTunnel (new TunnelConfig (hops), outboundTunnel); + auto tunnel = tunnels.CreateTunnel (new TunnelConfig (hops), outboundTunnel); tunnel->SetTunnelPool (shared_from_this ()); } - void TunnelPool::RecreateInboundTunnel (InboundTunnel * tunnel) + void TunnelPool::RecreateInboundTunnel (std::shared_ptr tunnel) { - OutboundTunnel * outboundTunnel = GetNextOutboundTunnel (); + auto outboundTunnel = GetNextOutboundTunnel (); if (!outboundTunnel) outboundTunnel = tunnels.GetNextOutboundTunnel (); LogPrint ("Re-creating destination inbound tunnel..."); - auto * newTunnel = tunnels.CreateTunnel (tunnel->GetTunnelConfig ()->Clone (), outboundTunnel); + auto newTunnel = tunnels.CreateTunnel (tunnel->GetTunnelConfig ()->Clone (), outboundTunnel); newTunnel->SetTunnelPool (shared_from_this()); } void TunnelPool::CreateOutboundTunnel () { - InboundTunnel * inboundTunnel = GetNextInboundTunnel (); + auto inboundTunnel = GetNextInboundTunnel (); if (!inboundTunnel) inboundTunnel = tunnels.GetNextInboundTunnel (); if (inboundTunnel) @@ -331,7 +331,7 @@ namespace tunnel hops.push_back (hop); } - auto * tunnel = tunnels.CreateTunnel ( + auto tunnel = tunnels.CreateTunnel ( new TunnelConfig (hops, inboundTunnel->GetTunnelConfig ())); tunnel->SetTunnelPool (shared_from_this ()); } @@ -339,15 +339,15 @@ namespace tunnel LogPrint ("Can't create outbound tunnel. No inbound tunnels found"); } - void TunnelPool::RecreateOutboundTunnel (OutboundTunnel * tunnel) + void TunnelPool::RecreateOutboundTunnel (std::shared_ptr tunnel) { - InboundTunnel * inboundTunnel = GetNextInboundTunnel (); + auto inboundTunnel = GetNextInboundTunnel (); if (!inboundTunnel) inboundTunnel = tunnels.GetNextInboundTunnel (); if (inboundTunnel) { LogPrint ("Re-creating destination outbound tunnel..."); - auto * newTunnel = tunnels.CreateTunnel ( + auto newTunnel = tunnels.CreateTunnel ( tunnel->GetTunnelConfig ()->Clone (inboundTunnel->GetTunnelConfig ())); newTunnel->SetTunnelPool (shared_from_this ()); } diff --git a/TunnelPool.h b/TunnelPool.h index 2bc645b3..fb057dc0 100644 --- a/TunnelPool.h +++ b/TunnelPool.h @@ -34,13 +34,13 @@ namespace tunnel void SetLocalDestination (i2p::garlic::GarlicDestination * destination) { m_LocalDestination = destination; }; void CreateTunnels (); - void TunnelCreated (InboundTunnel * createdTunnel); - void TunnelExpired (InboundTunnel * expiredTunnel); - void TunnelCreated (OutboundTunnel * createdTunnel); - void TunnelExpired (OutboundTunnel * expiredTunnel); - std::vector GetInboundTunnels (int num) const; - OutboundTunnel * GetNextOutboundTunnel (OutboundTunnel * suggested = nullptr) const; - InboundTunnel * GetNextInboundTunnel (InboundTunnel * suggested = nullptr) const; + void TunnelCreated (std::shared_ptr createdTunnel); + void TunnelExpired (std::shared_ptr expiredTunnel); + void TunnelCreated (std::shared_ptr createdTunnel); + void TunnelExpired (std::shared_ptr expiredTunnel); + std::vector > GetInboundTunnels (int num) const; + std::shared_ptr GetNextOutboundTunnel (std::shared_ptr suggested = nullptr) const; + std::shared_ptr GetNextInboundTunnel (std::shared_ptr suggested = nullptr) const; void TestTunnels (); void ProcessGarlicMessage (I2NPMessage * msg); @@ -54,8 +54,8 @@ namespace tunnel void CreateInboundTunnel (); void CreateOutboundTunnel (); - void RecreateInboundTunnel (InboundTunnel * tunnel); - void RecreateOutboundTunnel (OutboundTunnel * tunnel); + void RecreateInboundTunnel (std::shared_ptr tunnel); + void RecreateOutboundTunnel (std::shared_ptr tunnel); template typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels, typename TTunnels::value_type suggested = nullptr) const; @@ -66,10 +66,10 @@ namespace tunnel i2p::garlic::GarlicDestination * m_LocalDestination; int m_NumInboundHops, m_NumOutboundHops, m_NumTunnels; mutable std::mutex m_InboundTunnelsMutex; - std::set m_InboundTunnels; // recent tunnel appears first + std::set, TunnelCreationTimeCmp> m_InboundTunnels; // recent tunnel appears first mutable std::mutex m_OutboundTunnelsMutex; - std::set m_OutboundTunnels; - std::map > m_Tests; + std::set, TunnelCreationTimeCmp> m_OutboundTunnels; + std::map, std::shared_ptr > > m_Tests; bool m_IsActive; public: