mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
limit max number of resends
This commit is contained in:
parent
2f8274a7b3
commit
921ba9a9d6
@ -176,6 +176,7 @@ namespace stream
|
|||||||
SendQuickAck (); // send ack for close explicitly?
|
SendQuickAck (); // send ack for close explicitly?
|
||||||
m_IsOpen = false;
|
m_IsOpen = false;
|
||||||
m_ReceiveTimer.cancel ();
|
m_ReceiveTimer.cancel ();
|
||||||
|
m_ResendTimer.cancel ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +428,16 @@ namespace stream
|
|||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
{
|
{
|
||||||
for (auto it : m_SentPackets)
|
for (auto it : m_SentPackets)
|
||||||
SendPacket (it->GetBuffer (), it->GetLength ());
|
{
|
||||||
|
it->numResendAttempts++;
|
||||||
|
if (it->numResendAttempts <= MAX_NUM_RESEND_ATTEMPTS)
|
||||||
|
SendPacket (it->GetBuffer (), it->GetLength ());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Close ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
ScheduleResend ();
|
ScheduleResend ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,15 @@ namespace stream
|
|||||||
const size_t MAX_PACKET_SIZE = 4096;
|
const size_t MAX_PACKET_SIZE = 4096;
|
||||||
const size_t COMPRESSION_THRESHOLD_SIZE = 66;
|
const size_t COMPRESSION_THRESHOLD_SIZE = 66;
|
||||||
const int RESEND_TIMEOUT = 10; // in seconds
|
const int RESEND_TIMEOUT = 10; // in seconds
|
||||||
|
const int MAX_NUM_RESEND_ATTEMPTS = 5;
|
||||||
|
|
||||||
struct Packet
|
struct Packet
|
||||||
{
|
{
|
||||||
uint8_t buf[MAX_PACKET_SIZE];
|
uint8_t buf[MAX_PACKET_SIZE];
|
||||||
size_t len, offset;
|
size_t len, offset;
|
||||||
|
int numResendAttempts;
|
||||||
Packet (): len (0), offset (0) {};
|
|
||||||
|
Packet (): len (0), offset (0), numResendAttempts (0) {};
|
||||||
uint8_t * GetBuffer () { return buf + offset; };
|
uint8_t * GetBuffer () { return buf + offset; };
|
||||||
size_t GetLength () const { return len - offset; };
|
size_t GetLength () const { return len - offset; };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user