avoid race condition

This commit is contained in:
orignal 2014-06-26 15:41:12 -04:00
parent acbe0d801d
commit 9ad76aa0cf
2 changed files with 4 additions and 1 deletions

View file

@ -48,6 +48,7 @@ namespace tunnel
TunnelMessageBlock block; TunnelMessageBlock block;
block.deliveryType = eDeliveryTypeLocal; block.deliveryType = eDeliveryTypeLocal;
block.data = msg; block.data = msg;
std::unique_lock<std::mutex> l(m_SendMutex);
m_Gateway.SendTunnelDataMsg (block); m_Gateway.SendTunnelDataMsg (block);
} }
@ -81,4 +82,4 @@ namespace tunnel
} }
} }
} }
} }

View file

@ -2,6 +2,7 @@
#define TRANSIT_TUNNEL_H__ #define TRANSIT_TUNNEL_H__
#include <inttypes.h> #include <inttypes.h>
#include <mutex>
#include "aes.h" #include "aes.h"
#include "I2NPProtocol.h" #include "I2NPProtocol.h"
#include "TunnelEndpoint.h" #include "TunnelEndpoint.h"
@ -55,6 +56,7 @@ namespace tunnel
private: private:
std::mutex m_SendMutex;
TunnelGateway m_Gateway; TunnelGateway m_Gateway;
}; };