mirror of
https://github.com/transmission/transmission
synced 2025-03-12 23:23:54 +00:00
refactor: respond immediately to block requests from peer (#7029)
* refactor: respond immediately to block requests from peer * refactor: extract `fill_output_buffer()` impl method
This commit is contained in:
parent
47eb4ee2bc
commit
49e0e59763
1 changed files with 12 additions and 10 deletions
|
@ -559,6 +559,8 @@ private:
|
|||
if (can_add_request_from_peer(req))
|
||||
{
|
||||
peer_requested_.emplace_back(req);
|
||||
|
||||
fill_output_buffer(tr_time(), tr_time_msec());
|
||||
}
|
||||
else if (io_->supports_fext())
|
||||
{
|
||||
|
@ -607,7 +609,14 @@ private:
|
|||
void maybe_send_metadata_requests(time_t now) const;
|
||||
[[nodiscard]] size_t add_next_metadata_piece();
|
||||
[[nodiscard]] size_t add_next_block(time_t now_sec, uint64_t now_msec);
|
||||
[[nodiscard]] size_t fill_output_buffer(time_t now_sec, uint64_t now_msec);
|
||||
|
||||
[[nodiscard]] size_t fill_output_buffer_impl(time_t now_sec, uint64_t now_msec);
|
||||
void fill_output_buffer(time_t now_sec, uint64_t now_msec)
|
||||
{
|
||||
while (fill_output_buffer_impl(now_sec, now_msec) != 0U)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
|
@ -1834,14 +1843,7 @@ void tr_peerMsgsImpl::pulse()
|
|||
update_desired_request_count();
|
||||
maybe_send_block_requests();
|
||||
maybe_send_metadata_requests(now_sec);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (fill_output_buffer(now_sec, now_msec) == 0U)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
fill_output_buffer(now_sec, now_msec);
|
||||
}
|
||||
|
||||
void tr_peerMsgsImpl::maybe_send_metadata_requests(time_t now) const
|
||||
|
@ -1901,7 +1903,7 @@ void tr_peerMsgsImpl::check_request_timeout(time_t now)
|
|||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t tr_peerMsgsImpl::fill_output_buffer(time_t now_sec, uint64_t now_msec)
|
||||
[[nodiscard]] size_t tr_peerMsgsImpl::fill_output_buffer_impl(time_t now_sec, uint64_t now_msec)
|
||||
{
|
||||
auto n_bytes_written = size_t{};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue