Fix poll_capacity to wake in combination with max_send_buffer_size

This commit is contained in:
Sean McArthur
2021-12-08 17:38:41 -08:00
parent 88037ae0ab
commit a5c60b24de
3 changed files with 90 additions and 0 deletions

View File

@@ -741,6 +741,11 @@ 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();
// Assign the capacity back to the connection that
// was just consumed from the stream in the previous
// line.

View File

@@ -279,6 +279,17 @@ impl Stream {
}
}
/// If the capacity was limited because of the max_send_buffer_size,
/// then consider waking the send task again...
pub fn notify_if_can_buffer_more(&mut self) {
// Only notify if the capacity exceeds the amount of buffered data
if self.send_flow.available() > self.buffered_send_data {
self.send_capacity_inc = true;
tracing::trace!(" notifying task");
self.notify_send();
}
}
/// Returns `Err` when the decrement cannot be completed due to overflow.
pub fn dec_content_length(&mut self, len: usize) -> Result<(), ()> {
match self.content_length {