Skip to content

Commit

Permalink
Resolve stopped/received_reset futures on lost connections
Browse files Browse the repository at this point in the history
If a connection is lost before a stream becomes closed, these would
otherwise never complete.
  • Loading branch information
Ralith committed Jun 5, 2024
1 parent 2ad6dbb commit a7c697e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions quinn/src/recv_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ impl RecvStream {
Poll::Ready(Ok(Some(error_code)))
}
Ok(None) => {
if let Some(e) = &conn.error {
return Poll::Ready(Err(e.clone().into()));
}
// Resets always notify readers, since a reset is an immediate read error. We
// could introduce a dedicated channel to reduce the risk of spurious wakeups,
// but that increased complexity is probably not justified, as an application
Expand Down
3 changes: 3 additions & 0 deletions quinn/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ impl SendStream {
Err(_) => Poll::Ready(Ok(None)),
Ok(Some(error_code)) => Poll::Ready(Ok(Some(error_code))),
Ok(None) => {
if let Some(e) = &conn.error {
return Poll::Ready(Err(e.clone().into()));
}
conn.stopped.insert(self.stream, cx.waker().clone());
Poll::Pending
}
Expand Down

0 comments on commit a7c697e

Please sign in to comment.