mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
don't send Ack with NACK immediately but after 2 milliseconds
This commit is contained in:
parent
75c2cb751f
commit
530c353b00
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
* Copyright (c) 2013-2024, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
|
@ -179,13 +179,9 @@ namespace stream
|
||||||
{
|
{
|
||||||
if (!m_IsAckSendScheduled)
|
if (!m_IsAckSendScheduled)
|
||||||
{
|
{
|
||||||
m_IsAckSendScheduled = true;
|
|
||||||
auto ackTimeout = m_RTT/10;
|
auto ackTimeout = m_RTT/10;
|
||||||
if (ackTimeout > m_AckDelay) ackTimeout = m_AckDelay;
|
if (ackTimeout > m_AckDelay) ackTimeout = m_AckDelay;
|
||||||
else if (ackTimeout < MIN_SEND_ACK_TIMEOUT) ackTimeout = MIN_SEND_ACK_TIMEOUT;
|
ScheduleAck (ackTimeout);
|
||||||
m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(ackTimeout));
|
|
||||||
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer,
|
|
||||||
shared_from_this (), std::placeholders::_1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (packet->IsSYN ())
|
else if (packet->IsSYN ())
|
||||||
|
@ -207,23 +203,11 @@ namespace stream
|
||||||
// save message and wait for missing message again
|
// save message and wait for missing message again
|
||||||
SavePacket (packet);
|
SavePacket (packet);
|
||||||
if (m_LastReceivedSequenceNumber >= 0)
|
if (m_LastReceivedSequenceNumber >= 0)
|
||||||
{
|
// send NACKs for missing messages with minimal timeout
|
||||||
// send NACKs for missing messages ASAP
|
ScheduleAck (MIN_SEND_ACK_TIMEOUT);
|
||||||
if (m_IsAckSendScheduled)
|
|
||||||
{
|
|
||||||
m_IsAckSendScheduled = false;
|
|
||||||
m_AckSendTimer.cancel ();
|
|
||||||
}
|
|
||||||
SendQuickAck ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// wait for SYN
|
// wait for SYN
|
||||||
m_IsAckSendScheduled = true;
|
ScheduleAck (SYN_TIMEOUT);
|
||||||
m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(SYN_TIMEOUT));
|
|
||||||
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer,
|
|
||||||
shared_from_this (), std::placeholders::_1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1029,6 +1013,17 @@ namespace stream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Stream::ScheduleAck (int timeout)
|
||||||
|
{
|
||||||
|
if (m_IsAckSendScheduled)
|
||||||
|
m_AckSendTimer.cancel ();
|
||||||
|
m_IsAckSendScheduled = true;
|
||||||
|
if (timeout < MIN_SEND_ACK_TIMEOUT) timeout = MIN_SEND_ACK_TIMEOUT;
|
||||||
|
m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(timeout));
|
||||||
|
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer,
|
||||||
|
shared_from_this (), std::placeholders::_1));
|
||||||
|
}
|
||||||
|
|
||||||
void Stream::HandleAckSendTimer (const boost::system::error_code& ecode)
|
void Stream::HandleAckSendTimer (const boost::system::error_code& ecode)
|
||||||
{
|
{
|
||||||
if (m_IsAckSendScheduled)
|
if (m_IsAckSendScheduled)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
* Copyright (c) 2013-2024, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
|
@ -227,6 +227,7 @@ namespace stream
|
||||||
|
|
||||||
void ScheduleResend ();
|
void ScheduleResend ();
|
||||||
void HandleResendTimer (const boost::system::error_code& ecode);
|
void HandleResendTimer (const boost::system::error_code& ecode);
|
||||||
|
void ScheduleAck (int timeout);
|
||||||
void HandleAckSendTimer (const boost::system::error_code& ecode);
|
void HandleAckSendTimer (const boost::system::error_code& ecode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue