From ea27a5625c38614c4603c781cd166bf840300659 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 12 Nov 2024 08:16:20 -0800 Subject: [PATCH] fix: notify_recv after send_reset() in reset_on_recv_stream_err() to ensure local stream is released properly (#816) Similar to what have been done in fn send_reset(), we should notify RecvStream that is parked after send_reset(). Co-authored-by: Jiahao Liang --- src/proto/streams/streams.rs | 3 +++ tests/h2-tests/tests/stream_states.rs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/proto/streams/streams.rs b/src/proto/streams/streams.rs index 132d91bd..7b5c7669 100644 --- a/src/proto/streams/streams.rs +++ b/src/proto/streams/streams.rs @@ -1576,6 +1576,9 @@ impl Actions { // Reset the stream. self.send .send_reset(reason, initiator, buffer, stream, counts, &mut self.task); + self.recv.enqueue_reset_expiration(stream, counts); + // if a RecvStream is parked, ensure it's notified + stream.notify_recv(); Ok(()) } else { tracing::warn!( diff --git a/tests/h2-tests/tests/stream_states.rs b/tests/h2-tests/tests/stream_states.rs index 9a377d79..facd367e 100644 --- a/tests/h2-tests/tests/stream_states.rs +++ b/tests/h2-tests/tests/stream_states.rs @@ -536,7 +536,12 @@ async fn recv_next_stream_id_updated_by_malformed_headers() { client.recv_frame(frames::go_away(1).protocol_error()).await; }; let srv = async move { - let mut srv = server::handshake(io).await.expect("handshake"); + let mut srv = server::Builder::new() + // forget the bad stream immediately + .max_concurrent_reset_streams(0) + .handshake::<_, Bytes>(io) + .await + .expect("handshake"); let res = srv.next().await.unwrap(); let err = res.unwrap_err(); assert_eq!(err.reason(), Some(h2::Reason::PROTOCOL_ERROR));