transit tunnel gateway batching

This commit is contained in:
orignal 2015-01-23 22:05:33 -05:00
parent 82103e6a39
commit 1dc166f0f8
4 changed files with 25 additions and 9 deletions

View File

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

View File

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

View File

@ -70,9 +70,15 @@ namespace tunnel
block.deliveryType = eDeliveryTypeLocal;
block.data = msg;
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)
{
EncryptTunnelMsg (tunnelMsg);

View File

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