Skip to content

Commit f1f99e0

Browse files
committed
fix: pending_open streams taking capacity
1 parent 7dec3c2 commit f1f99e0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/proto/streams/prioritize.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,15 @@ impl Prioritize {
184184
stream.requested_send_capacity =
185185
cmp::min(stream.buffered_send_data, WindowSize::MAX as usize) as WindowSize;
186186

187-
self.try_assign_capacity(stream);
187+
// `try_assign_capacity` will queue the stream to `pending_capacity` if the capcaity
188+
// cannot be assigned at the time it is called.
189+
//
190+
// Streams over the max concurrent count will still call `send_data` so we should be
191+
// careful not to put it into `pending_capacity` as it will starve the connection
192+
// capacity for other streams
193+
if !stream.is_pending_open {
194+
self.try_assign_capacity(stream);
195+
}
188196
}
189197

190198
if frame.is_end_stream() {
@@ -474,13 +482,7 @@ impl Prioritize {
474482
//
475483
// In this case, the stream needs to be queued up for when the
476484
// connection has more capacity.
477-
if stream.is_send_ready() {
478-
// Prioritize assigning capacity to a send-ready stream
479-
// See https://github.com/hyperium/hyper/issues/3338
480-
self.pending_capacity.push_front(stream);
481-
} else {
482-
self.pending_capacity.push(stream);
483-
}
485+
self.pending_capacity.push(stream);
484486
}
485487

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

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

0 commit comments

Comments
 (0)