Skip to content

Commit 1c72006

Browse files
committed
fix(h2): improve errors emitted by H2 stream shutdown
1 parent 684f2fa commit 1c72006

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/proto/h2/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,21 @@ where
377377

378378
fn poll_shutdown(
379379
mut self: Pin<&mut Self>,
380-
_cx: &mut Context<'_>,
380+
cx: &mut Context<'_>,
381381
) -> Poll<Result<(), io::Error>> {
382-
Poll::Ready(self.send_stream.write(&[], true))
382+
if self.send_stream.write(&[], true).is_ok() {
383+
return Poll::Ready(Ok(()))
384+
}
385+
386+
Poll::Ready(Err(h2_to_io_error(
387+
match ready!(self.send_stream.poll_reset(cx)) {
388+
Ok(Reason::NO_ERROR) | Ok(Reason::CANCEL) | Ok(Reason::STREAM_CLOSED) => {
389+
return Poll::Ready(Ok(()))
390+
}
391+
Ok(reason) => reason.into(),
392+
Err(e) => e,
393+
},
394+
)))
383395
}
384396
}
385397

0 commit comments

Comments
 (0)