mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
fix #1290. copy correct size if message didn't fit previous
This commit is contained in:
parent
d848ae332a
commit
bc3f02cb6b
@ -51,6 +51,19 @@ namespace tunnel
|
|||||||
// create fragments
|
// create fragments
|
||||||
const std::shared_ptr<I2NPMessage> & msg = block.data;
|
const std::shared_ptr<I2NPMessage> & msg = block.data;
|
||||||
size_t fullMsgLen = diLen + msg->GetLength () + 2; // delivery instructions + payload + 2 bytes length
|
size_t fullMsgLen = diLen + msg->GetLength () + 2; // delivery instructions + payload + 2 bytes length
|
||||||
|
|
||||||
|
if (!messageCreated && fullMsgLen > m_RemainingSize) // check if we should complete previous message
|
||||||
|
{
|
||||||
|
size_t numFollowOnFragments = fullMsgLen / TUNNEL_DATA_MAX_PAYLOAD_SIZE;
|
||||||
|
// length of bytes doesn't fit full tunnel message
|
||||||
|
// every follow-on fragment adds 7 bytes
|
||||||
|
size_t nonFit = (fullMsgLen + numFollowOnFragments*7) % TUNNEL_DATA_MAX_PAYLOAD_SIZE;
|
||||||
|
if (!nonFit || nonFit > m_RemainingSize)
|
||||||
|
{
|
||||||
|
CompleteCurrentTunnelDataMessage ();
|
||||||
|
CreateCurrentTunnelDataMessage ();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (fullMsgLen <= m_RemainingSize)
|
if (fullMsgLen <= m_RemainingSize)
|
||||||
{
|
{
|
||||||
// message fits. First and last fragment
|
// message fits. First and last fragment
|
||||||
@ -65,18 +78,6 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!messageCreated) // check if we should complete previous message
|
|
||||||
{
|
|
||||||
size_t numFollowOnFragments = fullMsgLen / TUNNEL_DATA_MAX_PAYLOAD_SIZE;
|
|
||||||
// length of bytes don't fit full tunnel message
|
|
||||||
// every follow-on fragment adds 7 bytes
|
|
||||||
size_t nonFit = (fullMsgLen + numFollowOnFragments*7) % TUNNEL_DATA_MAX_PAYLOAD_SIZE;
|
|
||||||
if (!nonFit || nonFit > m_RemainingSize)
|
|
||||||
{
|
|
||||||
CompleteCurrentTunnelDataMessage ();
|
|
||||||
CreateCurrentTunnelDataMessage ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (diLen + 6 <= m_RemainingSize)
|
if (diLen + 6 <= m_RemainingSize)
|
||||||
{
|
{
|
||||||
// delivery instructions fit
|
// delivery instructions fit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user