From 92b96d9b15206ee5ab7aa3777947f45ec881c6a0 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 3 Apr 2014 12:19:12 -0400 Subject: [PATCH] fixed race condition --- Tunnel.cpp | 3 +++ Tunnel.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Tunnel.cpp b/Tunnel.cpp index 9ccf4219..4b831fbc 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -154,11 +154,14 @@ namespace tunnel else block.deliveryType = eDeliveryTypeLocal; block.data = msg; + + std::unique_lock l(m_SendMutex); m_Gateway.SendTunnelDataMsg (block); } void OutboundTunnel::SendTunnelDataMsg (std::vector msgs) { + std::unique_lock l(m_SendMutex); for (auto& it : msgs) m_Gateway.PutTunnelDataMsg (it); m_Gateway.SendBuffer (); diff --git a/Tunnel.h b/Tunnel.h index 4328ddb3..d1d77fe9 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include "Queue.h" @@ -83,6 +84,7 @@ namespace tunnel private: + std::mutex m_SendMutex; TunnelGateway m_Gateway; };