From 3e0f5d231dbb799627c8d4f2f80c057ab7cb031d Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 18 Apr 2022 15:47:35 -0400 Subject: [PATCH] send queue after batch of packets --- libi2pd/SSU2.cpp | 12 ++++++------ libi2pd/SSU2.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libi2pd/SSU2.cpp b/libi2pd/SSU2.cpp index 90a78bbd..467377a8 100644 --- a/libi2pd/SSU2.cpp +++ b/libi2pd/SSU2.cpp @@ -108,7 +108,7 @@ namespace transport SendQueue (); } - void SSU2Session::SendQueue () + bool SSU2Session::SendQueue () { if (!m_SendQueue.empty () && m_SentPackets.size () <= m_WindowSize) { @@ -149,7 +149,9 @@ namespace transport packet->nextResendTime = nextResend; m_SentPackets.emplace (packetNum, packet); } - } + return true; + } + return false; } void SSU2Session::SendFragmentedMessage (std::shared_ptr msg) @@ -747,10 +749,7 @@ namespace transport m_LastActivityTimestamp = i2p::util::GetSecondsSinceEpoch (); m_NumReceivedBytes += len; if (UpdateReceivePacketNum (packetNum)) - { HandlePayload (payload, payloadSize); - SendQueue (); // if we have something to send - } } void SSU2Session::HandlePayload (const uint8_t * buf, size_t len) @@ -1245,9 +1244,10 @@ namespace transport void SSU2Session::FlushData () { + bool sent = SendQueue (); // if we have something to send if (m_IsDataReceived) { - SendQuickAck (); + if (!sent) SendQuickAck (); m_Handler.Flush (); m_IsDataReceived = false; } diff --git a/libi2pd/SSU2.h b/libi2pd/SSU2.h index e2222b46..da8adcb3 100644 --- a/libi2pd/SSU2.h +++ b/libi2pd/SSU2.h @@ -159,7 +159,7 @@ namespace transport void Established (); void PostI2NPMessages (std::vector > msgs); - void SendQueue (); + bool SendQueue (); void SendFragmentedMessage (std::shared_ptr msg); void ProcessSessionRequest (Header& header, uint8_t * buf, size_t len);