Skip to content

Commit 1857605

Browse files
committed
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
1 parent 87c9be0 commit 1857605

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/proto/streams/recv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ impl Recv {
557557
}
558558

559559
pub fn is_end_stream(&self, stream: &store::Ptr) -> bool {
560-
if !stream.state.is_recv_closed() {
560+
if !stream.state.is_recv_end_stream() {
561561
return false;
562562
}
563563

src/proto/streams/state.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,13 @@ impl State {
409409
)
410410
}
411411

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

416-
pub fn is_recv_closed(&self) -> bool {
417-
matches!(
418-
self.inner,
419-
Closed(..) | HalfClosedRemote(..) | ReservedLocal
420-
)
417+
pub fn is_closed(&self) -> bool {
418+
matches!(self.inner, Closed(_))
421419
}
422420

423421
pub fn is_send_closed(&self) -> bool {

tests/h2-tests/tests/flow_control.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ async fn client_decrease_initial_window_size() {
13391339
conn.drive(async {
13401340
data(&mut body5, "body5 data2").await;
13411341
data(&mut body5, "body5 data3").await;
1342-
assert!(body3.is_end_stream());
1342+
assert!(!body3.is_end_stream());
13431343
})
13441344
.await;
13451345

0 commit comments

Comments
 (0)