mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
skip resent recently sessions during resend
This commit is contained in:
parent
f5b823a712
commit
124698854f
@ -987,6 +987,7 @@ namespace transport
|
|||||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
for (auto it: m_Sessions)
|
for (auto it: m_Sessions)
|
||||||
{
|
{
|
||||||
|
if (ts >= it.second->GetLastResendTime () + SSU2_RESEND_CHECK_TIMEOUT)
|
||||||
resentPacketsNum += it.second->Resend (ts);
|
resentPacketsNum += it.second->Resend (ts);
|
||||||
if (resentPacketsNum > SSU2_MAX_RESEND_PACKETS) break;
|
if (resentPacketsNum > SSU2_MAX_RESEND_PACKETS) break;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,8 @@ namespace transport
|
|||||||
m_WindowSize (SSU2_MIN_WINDOW_SIZE),
|
m_WindowSize (SSU2_MIN_WINDOW_SIZE),
|
||||||
m_RTO (SSU2_INITIAL_RTO), m_RelayTag (0),m_ConnectTimer (server.GetService ()),
|
m_RTO (SSU2_INITIAL_RTO), m_RelayTag (0),m_ConnectTimer (server.GetService ()),
|
||||||
m_TerminationReason (eSSU2TerminationReasonNormalClose),
|
m_TerminationReason (eSSU2TerminationReasonNormalClose),
|
||||||
m_MaxPayloadSize (SSU2_MIN_PACKET_SIZE - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - 32) // min size
|
m_MaxPayloadSize (SSU2_MIN_PACKET_SIZE - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - 32), // min size
|
||||||
|
m_LastResendTime (0)
|
||||||
{
|
{
|
||||||
m_NoiseState.reset (new i2p::crypto::NoiseSymmetricState);
|
m_NoiseState.reset (new i2p::crypto::NoiseSymmetricState);
|
||||||
if (in_RemoteRouter && m_Address)
|
if (in_RemoteRouter && m_Address)
|
||||||
@ -565,6 +566,7 @@ namespace transport
|
|||||||
it++;
|
it++;
|
||||||
if (!resentPackets.empty ())
|
if (!resentPackets.empty ())
|
||||||
{
|
{
|
||||||
|
m_LastResendTime = ts;
|
||||||
#if (__cplusplus >= 201703L) // C++ 17 or higher
|
#if (__cplusplus >= 201703L) // C++ 17 or higher
|
||||||
m_SentPackets.merge (resentPackets);
|
m_SentPackets.merge (resentPackets);
|
||||||
#else
|
#else
|
||||||
|
@ -256,7 +256,8 @@ namespace transport
|
|||||||
void SendLocalRouterInfo (bool update) override;
|
void SendLocalRouterInfo (bool update) override;
|
||||||
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) override;
|
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) override;
|
||||||
uint32_t GetRelayTag () const override { return m_RelayTag; };
|
uint32_t GetRelayTag () const override { return m_RelayTag; };
|
||||||
size_t Resend (uint64_t ts); // return number or resent packets
|
size_t Resend (uint64_t ts); // return number of resent packets
|
||||||
|
uint64_t GetLastResendTime () const { return m_LastResendTime; };
|
||||||
bool IsEstablished () const override { return m_State == eSSU2SessionStateEstablished; };
|
bool IsEstablished () const override { return m_State == eSSU2SessionStateEstablished; };
|
||||||
uint64_t GetConnID () const { return m_SourceConnID; };
|
uint64_t GetConnID () const { return m_SourceConnID; };
|
||||||
SSU2SessionState GetState () const { return m_State; };
|
SSU2SessionState GetState () const { return m_State; };
|
||||||
@ -369,6 +370,7 @@ namespace transport
|
|||||||
size_t m_MaxPayloadSize;
|
size_t m_MaxPayloadSize;
|
||||||
std::unique_ptr<i2p::data::IdentHash> m_PathChallenge;
|
std::unique_ptr<i2p::data::IdentHash> m_PathChallenge;
|
||||||
std::unordered_map<uint32_t, uint32_t> m_ReceivedI2NPMsgIDs; // msgID -> timestamp in seconds
|
std::unordered_map<uint32_t, uint32_t> m_ReceivedI2NPMsgIDs; // msgID -> timestamp in seconds
|
||||||
|
uint64_t m_LastResendTime; // in milliseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
|
inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
|
||||||
|
Loading…
Reference in New Issue
Block a user