mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
drop earlier if outgoing queue is semi-full
This commit is contained in:
parent
83cb3a1820
commit
96cf6ca531
@ -1250,8 +1250,13 @@ namespace transport
|
|||||||
void NTCP2Session::PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs)
|
void NTCP2Session::PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs)
|
||||||
{
|
{
|
||||||
if (m_IsTerminated) return;
|
if (m_IsTerminated) return;
|
||||||
|
bool isSemiFull = m_SendQueue.size () > NTCP2_MAX_OUTGOING_QUEUE_SIZE/2;
|
||||||
for (auto it: msgs)
|
for (auto it: msgs)
|
||||||
m_SendQueue.push_back (std::move (it));
|
if (isSemiFull && it->onDrop)
|
||||||
|
it->Drop (); // drop earlier because we can handle it
|
||||||
|
else
|
||||||
|
m_SendQueue.push_back (std::move (it));
|
||||||
|
|
||||||
if (!m_IsSending)
|
if (!m_IsSending)
|
||||||
SendQueue ();
|
SendQueue ();
|
||||||
else if (m_SendQueue.size () > NTCP2_MAX_OUTGOING_QUEUE_SIZE)
|
else if (m_SendQueue.size () > NTCP2_MAX_OUTGOING_QUEUE_SIZE)
|
||||||
|
@ -351,8 +351,12 @@ namespace transport
|
|||||||
void SSU2Session::PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs)
|
void SSU2Session::PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs)
|
||||||
{
|
{
|
||||||
if (m_State == eSSU2SessionStateTerminated) return;
|
if (m_State == eSSU2SessionStateTerminated) return;
|
||||||
|
bool isSemiFull = m_SendQueue.size () > SSU2_MAX_OUTGOING_QUEUE_SIZE/2;
|
||||||
for (auto it: msgs)
|
for (auto it: msgs)
|
||||||
m_SendQueue.push_back (std::move (it));
|
if (isSemiFull && it->onDrop)
|
||||||
|
it->Drop (); // drop earlier because we can handle it
|
||||||
|
else
|
||||||
|
m_SendQueue.push_back (std::move (it));
|
||||||
SendQueue ();
|
SendQueue ();
|
||||||
|
|
||||||
if (m_SendQueue.size () > 0) // windows is full
|
if (m_SendQueue.size () > 0) // windows is full
|
||||||
|
Loading…
Reference in New Issue
Block a user