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 4, 2024
1 parent 848885b commit dad7572
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 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_end_stream() {
return false;
}

Expand Down
7 changes: 2 additions & 5 deletions src/proto/streams/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 dad7572

Please sign in to comment.