Skip to content

Commit

Permalink
Fix RecvStream::is_end_stream(): return true only when END_STREAM is …
Browse files Browse the repository at this point in the history
…received

Before this change, it returned true on other types of disconnection as
well.

Fixes #806
  • Loading branch information
eaufavor committed Nov 12, 2024
1 parent 87c9be0 commit 1857605
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/proto/streams/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_recv_end_stream() {
return false;
}

Expand Down
12 changes: 5 additions & 7 deletions src/proto/streams/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,13 @@ impl State {
)
}

pub fn is_closed(&self) -> bool {
matches!(self.inner, Closed(_))
pub fn is_recv_end_stream(&self) -> bool {
// In either case END_STREAM has been received
matches!(self.inner, Closed(Cause::EndStream) | HalfClosedRemote(..))
}

pub fn is_recv_closed(&self) -> bool {
matches!(
self.inner,
Closed(..) | HalfClosedRemote(..) | ReservedLocal
)
pub fn is_closed(&self) -> bool {
matches!(self.inner, Closed(_))
}

pub fn is_send_closed(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion tests/h2-tests/tests/flow_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1857605

Please sign in to comment.