Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix window size decrement of send-closed streams #830

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/proto/streams/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,16 @@ impl Send {
store.try_for_each(|mut stream| {
let stream = &mut *stream;

if stream.state.is_send_closed() && stream.buffered_send_data == 0 {
tracing::trace!(
"skipping send-closed stream; id={:?}; flow={:?}",
stream.id,
stream.send_flow
);

return Ok(());
}

tracing::trace!(
"decrementing stream window; id={:?}; decr={}; flow={:?}",
stream.id,
Expand Down
6 changes: 2 additions & 4 deletions tests/h2-tests/tests/flow_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ async fn poll_capacity_wakeup_after_window_update() {
}

#[tokio::test]
async fn window_size_decremented_past_zero() {
async fn window_size_does_not_underflow() {
h2_support::trace_init!();
let (io, mut client) = mock::new();

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

// just keep it open
let res = poll_fn(move |cx| srv.poll_closed(cx)).await;
nox marked this conversation as resolved.
Show resolved Hide resolved
tracing::debug!("{:?}", res);
poll_fn(move |cx| srv.poll_closed(cx)).await.unwrap();
};

join(client, srv).await;
Expand Down
Loading