Browse Source

transit tunnel gateway batching

pull/151/head
orignal 10 years ago
parent
commit
1dc166f0f8
  1. 15
      I2NPProtocol.cpp
  2. 2
      I2NPProtocol.h
  3. 8
      TransitTunnel.cpp
  4. 1
      TransitTunnel.h

15
I2NPProtocol.cpp

@ -560,15 +560,19 @@ namespace i2p
{ {
if (msg) if (msg)
{ {
if (msg->GetTypeID () == eI2NPTunnelData) switch (msg->GetTypeID ())
{ {
case eI2NPTunnelData:
LogPrint ("TunnelData"); LogPrint ("TunnelData");
m_TunnelMsgs.push_back (msg); m_TunnelMsgs.push_back (msg);
} break;
else LogPrint ("TunnelGateway");
m_TunnelGatewayMsgs.push_back (msg);
default:
HandleI2NPMessage (msg); HandleI2NPMessage (msg);
} }
} }
}
void I2NPMessagesHandler::Flush () void I2NPMessagesHandler::Flush ()
{ {
@ -577,5 +581,10 @@ namespace i2p
i2p::tunnel::tunnels.PostTunnelData (m_TunnelMsgs); i2p::tunnel::tunnels.PostTunnelData (m_TunnelMsgs);
m_TunnelMsgs.clear (); m_TunnelMsgs.clear ();
} }
if (!m_TunnelGatewayMsgs.empty ())
{
i2p::tunnel::tunnels.PostTunnelData (m_TunnelMsgs);
m_TunnelGatewayMsgs.clear ();
}
} }
} }

2
I2NPProtocol.h

@ -226,7 +226,7 @@ namespace tunnel
private: private:
std::vector<I2NPMessage *> m_TunnelMsgs; std::vector<I2NPMessage *> m_TunnelMsgs, m_TunnelGatewayMsgs;
}; };
} }

8
TransitTunnel.cpp

@ -70,7 +70,13 @@ namespace tunnel
block.deliveryType = eDeliveryTypeLocal; block.deliveryType = eDeliveryTypeLocal;
block.data = msg; block.data = msg;
std::unique_lock<std::mutex> l(m_SendMutex); std::unique_lock<std::mutex> l(m_SendMutex);
m_Gateway.SendTunnelDataMsg (block); m_Gateway.PutTunnelDataMsg (block);
}
void TransitTunnelGateway::FlushTunnelDataMsgs ()
{
LogPrint (eLogDebug, "TransitTunnel: gateway flush");
m_Gateway.SendBuffer ();
} }
void TransitTunnelEndpoint::HandleTunnelDataMsg (i2p::I2NPMessage * tunnelMsg) void TransitTunnelEndpoint::HandleTunnelDataMsg (i2p::I2NPMessage * tunnelMsg)

1
TransitTunnel.h

@ -73,6 +73,7 @@ namespace tunnel
layerKey, ivKey), m_Gateway(this) {}; layerKey, ivKey), m_Gateway(this) {};
void SendTunnelDataMsg (i2p::I2NPMessage * msg); void SendTunnelDataMsg (i2p::I2NPMessage * msg);
void FlushTunnelDataMsgs ();
size_t GetNumTransmittedBytes () const { return m_Gateway.GetNumSentBytes (); }; size_t GetNumTransmittedBytes () const { return m_Gateway.GetNumSentBytes (); };
private: private:

Loading…
Cancel
Save