Skip to content

Commit

Permalink
fix: pending_open streams taking capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
dswij committed Jan 6, 2024
1 parent 7dec3c2 commit f1f99e0
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 @@ -184,7 +184,15 @@ impl Prioritize {
stream.requested_send_capacity =
cmp::min(stream.buffered_send_data, WindowSize::MAX as usize) as WindowSize;

self.try_assign_capacity(stream);
// `try_assign_capacity` will queue the stream to `pending_capacity` if the capcaity
// cannot be assigned at the time it is called.
//
// Streams over the max concurrent count will still call `send_data` so we should be
// careful not to put it into `pending_capacity` as it will starve the connection
// capacity for other streams
if !stream.is_pending_open {
self.try_assign_capacity(stream);
}
}

if frame.is_end_stream() {
Expand Down Expand Up @@ -474,13 +482,7 @@ impl Prioritize {
//
// In this case, the stream needs to be queued up for when the
// connection has more capacity.
if stream.is_send_ready() {
// Prioritize assigning capacity to a send-ready stream
// See https://github.com/hyperium/hyper/issues/3338
self.pending_capacity.push_front(stream);
} else {
self.pending_capacity.push(stream);
}
self.pending_capacity.push(stream);
}

// If data is buffered and the stream is send ready, then
Expand Down Expand Up @@ -528,6 +530,7 @@ impl Prioritize {
loop {
if let Some(mut stream) = self.pop_pending_open(store, counts) {
self.pending_send.push_front(&mut stream);
self.try_assign_capacity(&mut stream);
}

match self.pop_frame(buffer, store, max_frame_len, counts) {
Expand Down

0 comments on commit f1f99e0

Please sign in to comment.