Skip to content

Commit 4793ad2

Browse files
committed
Fix window size decrement of send-closed streams
Send-closed streams should be skipped when decreasing window size, as they are skipped when increasing it.
1 parent d7c56f4 commit 4793ad2

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/proto/streams/send.rs

+10
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,16 @@ impl Send {
466466
store.try_for_each(|mut stream| {
467467
let stream = &mut *stream;
468468

469+
if stream.state.is_send_closed() && stream.buffered_send_data == 0 {
470+
tracing::trace!(
471+
"skipping send-closed stream; id={:?}; flow={:?}",
472+
stream.id,
473+
stream.send_flow
474+
);
475+
476+
return Ok(());
477+
}
478+
469479
tracing::trace!(
470480
"decrementing stream window; id={:?}; decr={}; flow={:?}",
471481
stream.id,

tests/h2-tests/tests/flow_control.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,7 @@ async fn poll_capacity_wakeup_after_window_update() {
18591859
}
18601860

18611861
#[tokio::test]
1862-
async fn window_size_decremented_past_zero() {
1862+
async fn window_size_does_not_underflow() {
18631863
h2_support::trace_init!();
18641864
let (io, mut client) = mock::new();
18651865

@@ -1891,9 +1891,7 @@ async fn window_size_decremented_past_zero() {
18911891
let builder = server::Builder::new();
18921892
let mut srv = builder.handshake::<_, Bytes>(io).await.expect("handshake");
18931893

1894-
// just keep it open
1895-
let res = poll_fn(move |cx| srv.poll_closed(cx)).await;
1896-
tracing::debug!("{:?}", res);
1894+
poll_fn(move |cx| srv.poll_closed(cx)).await.unwrap();
18971895
};
18981896

18991897
join(client, srv).await;

0 commit comments

Comments
 (0)