Browse Source

fixed race condition

pull/51/head
orignal 11 years ago
parent
commit
92b96d9b15
  1. 3
      Tunnel.cpp
  2. 2
      Tunnel.h

3
Tunnel.cpp

@ -154,11 +154,14 @@ namespace tunnel @@ -154,11 +154,14 @@ namespace tunnel
else
block.deliveryType = eDeliveryTypeLocal;
block.data = msg;
std::unique_lock<std::mutex> l(m_SendMutex);
m_Gateway.SendTunnelDataMsg (block);
}
void OutboundTunnel::SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs)
{
std::unique_lock<std::mutex> l(m_SendMutex);
for (auto& it : msgs)
m_Gateway.PutTunnelDataMsg (it);
m_Gateway.SendBuffer ();

2
Tunnel.h

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include <vector>
#include <string>
#include <thread>
#include <mutex>
#include <cryptopp/modes.h>
#include <cryptopp/aes.h>
#include "Queue.h"
@ -83,6 +84,7 @@ namespace tunnel @@ -83,6 +84,7 @@ namespace tunnel
private:
std::mutex m_SendMutex;
TunnelGateway m_Gateway;
};

Loading…
Cancel
Save