From 05c297cb0b25f999dc51dc552021bbe675d8810c Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 27 Sep 2014 17:51:55 -0400 Subject: [PATCH] generate reandom tunnelMsgID --- Tunnel.cpp | 9 ++++----- Tunnel.h | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Tunnel.cpp b/Tunnel.cpp index 57c16184..cced48db 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -198,8 +198,7 @@ namespace tunnel Tunnels tunnels; - Tunnels::Tunnels (): m_IsRunning (false), m_IsTunnelCreated (false), - m_NextReplyMsgID (555), m_Thread (nullptr), m_ExploratoryPool (nullptr) + Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr), m_ExploratoryPool (nullptr) { } @@ -535,9 +534,9 @@ namespace tunnel TTunnel * Tunnels::CreateTunnel (TunnelConfig * config, OutboundTunnel * outboundTunnel) { TTunnel * newTunnel = new TTunnel (config); - m_PendingTunnels[m_NextReplyMsgID] = newTunnel; - newTunnel->Build (m_NextReplyMsgID, outboundTunnel); - m_NextReplyMsgID++; // TODO: should be atomic + uint32_t replyMsgID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); + m_PendingTunnels[replyMsgID] = newTunnel; + newTunnel->Build (replyMsgID, outboundTunnel); return newTunnel; } diff --git a/Tunnel.h b/Tunnel.h index 73a0e0c6..03a74018 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -146,8 +146,6 @@ namespace tunnel private: bool m_IsRunning; - bool m_IsTunnelCreated; // TODO: temporary - uint32_t m_NextReplyMsgID; // TODO: make it random later std::thread * m_Thread; std::map m_PendingTunnels; // by replyMsgID std::mutex m_InboundTunnelsMutex;