1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-29 19:16:23 +00:00

fix: std::clamp() assertion failure in maxAvailableReqs() (#5203)

This commit is contained in:
Charles Kerr 2023-03-11 22:25:21 -06:00 committed by GitHub
parent 900281eb1c
commit dabd29f2b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -619,7 +619,11 @@ private:
size_t constexpr Seconds = RequestBufSecs; size_t constexpr Seconds = RequestBufSecs;
size_t const estimated_blocks_in_period = (rate_bytes_per_second * Seconds) / tr_block_info::BlockSize; size_t const estimated_blocks_in_period = (rate_bytes_per_second * Seconds) / tr_block_info::BlockSize;
size_t const ceil = reqq ? *reqq : 250; size_t const ceil = reqq ? *reqq : 250;
return std::clamp(estimated_blocks_in_period, Floor, ceil);
auto max_reqs = estimated_blocks_in_period;
max_reqs = std::min(max_reqs, ceil);
max_reqs = std::max(max_reqs, Floor);
return max_reqs;
} }
void protocolSendRequest(struct peer_request const& req) void protocolSendRequest(struct peer_request const& req)