diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index 990261f3..4d0d3a60 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -1579,13 +1579,16 @@ namespace torrents { if (m_NumPieces >= MAX_NUM_PIECES) { - m_IncomingRequestsQueue.emplace_back (index, offset, length); - if (!m_IsRemoteChoked && m_IncomingRequestsQueue.size () > 5*MAX_NUM_PIECES) - { + if (m_IncomingRequestsQueue.size () < MAX_INCOMING_REQUESTS_QUEUE_SIZE) + m_IncomingRequestsQueue.emplace_back (index, offset, length); + else if (m_IsFast) + SendRejectRequestMsg (index, offset, length); + else if (!m_IsRemoteChoked) + { LogPrint (eLogDebug, "Torrents: Choke"); m_IsRemoteChoked = true; SendChokeMsg (); - } + } } else if (!SendRequestedBlock ({index, offset, length})) // block was not sent { @@ -1760,7 +1763,6 @@ namespace torrents { auto [q, l] = ExtractInteger (buf); if (l) m_MaxNumRequests = std::clamp ((size_t)q, MIN_NUM_REQUESTS, MAX_NUM_REQUESTS); - LogPrint (eLogDebug, "Torrents: max num requests ", m_MaxNumRequests); return l; } else if (key == "v") diff --git a/libi2pd_client/Torrents.h b/libi2pd_client/Torrents.h index c16d0baa..8eb2e7ca 100644 --- a/libi2pd_client/Torrents.h +++ b/libi2pd_client/Torrents.h @@ -44,7 +44,7 @@ namespace torrents constexpr size_t MAX_NUM_REQUESTS = 24; constexpr size_t MAX_NUM_PIECES = 6; constexpr size_t MAX_INCOMING_REQUESTS_QUEUE_SIZE = 32; - constexpr int PIECE_INACTIVITY_TIMEOUT = 60; // in seconds + constexpr int PIECE_INACTIVITY_TIMEOUT = 35; // in seconds constexpr int HANDSHAKE_RECEIVE_TIMEOUT = 20; // in seconds constexpr int BANDWIDTH_RATE_SAMPLING_INTERVAL = 20; // in milliseconds