Skip to content

Commit

Permalink
Avoid spurios wakups when sent capacity doesn't change
Browse files Browse the repository at this point in the history
Fixes #628
  • Loading branch information
vadim-eg committed Aug 3, 2022
1 parent 756384f commit ae03382
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/proto/streams/prioritize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,11 @@ impl Prioritize {
/// connection
pub fn reclaim_all_capacity(&mut self, stream: &mut store::Ptr, counts: &mut Counts) {
let available = stream.send_flow.available().as_size();
stream.send_flow.claim_capacity(available);
// Re-assign all capacity to the connection
self.assign_connection_capacity(available, stream, counts);
if available > 0 {
stream.send_flow.claim_capacity(available);
// Re-assign all capacity to the connection
self.assign_connection_capacity(available, stream, counts);
}
}

/// Reclaim just reserved capacity, not buffered capacity, and re-assign
Expand Down Expand Up @@ -749,11 +751,12 @@ impl Prioritize {
stream.buffered_send_data -= len as usize;
stream.requested_send_capacity -= len;

// If the capacity was limited because of the
// max_send_buffer_size, then consider waking
// the send task again...
stream.notify_if_can_buffer_more(self.max_buffer_size);

if stream_capacity > self.max_buffer_size {
// If the capacity was limited because of the
// max_send_buffer_size, then consider waking
// the send task again...
stream.notify_if_can_buffer_more(self.max_buffer_size);
}
// Assign the capacity back to the connection that
// was just consumed from the stream in the previous
// line.
Expand Down

0 comments on commit ae03382

Please sign in to comment.