From dad7572ddac9060a59c9a881190fc934bf352300 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Mon, 4 Nov 2024 08:37:01 -0800 Subject: [PATCH] Fix RecvStream::is_end_stream(): return true only when END_STREAM is received Before this change, it returned true on other types of disconnection as well. Fixes #806 --- src/proto/streams/recv.rs | 2 +- src/proto/streams/state.rs | 7 ++----- tests/h2-tests/tests/flow_control.rs | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/proto/streams/recv.rs b/src/proto/streams/recv.rs index a70527e2..2b8f3f0c 100644 --- a/src/proto/streams/recv.rs +++ b/src/proto/streams/recv.rs @@ -557,7 +557,7 @@ impl Recv { } pub fn is_end_stream(&self, stream: &store::Ptr) -> bool { - if !stream.state.is_recv_closed() { + if !stream.state.is_end_stream() { return false; } diff --git a/src/proto/streams/state.rs b/src/proto/streams/state.rs index 5256f09c..c47c94e1 100644 --- a/src/proto/streams/state.rs +++ b/src/proto/streams/state.rs @@ -413,11 +413,8 @@ impl State { matches!(self.inner, Closed(_)) } - pub fn is_recv_closed(&self) -> bool { - matches!( - self.inner, - Closed(..) | HalfClosedRemote(..) | ReservedLocal - ) + pub fn is_end_stream(&self) -> bool { + matches!(self.inner, Closed(Cause::EndStream)) } pub fn is_send_closed(&self) -> bool { diff --git a/tests/h2-tests/tests/flow_control.rs b/tests/h2-tests/tests/flow_control.rs index e3caaff5..292c303c 100644 --- a/tests/h2-tests/tests/flow_control.rs +++ b/tests/h2-tests/tests/flow_control.rs @@ -1339,7 +1339,7 @@ async fn client_decrease_initial_window_size() { conn.drive(async { data(&mut body5, "body5 data2").await; data(&mut body5, "body5 data3").await; - assert!(body3.is_end_stream()); + assert!(!body3.is_end_stream()); }) .await;