Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,12 @@ where
type Output = Result<(), crate::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.inner.maybe_close_connection_if_no_streams();
// Snapshot before checking for shutdown: the last reference may be
// dropped after the shutdown check, before inner.poll registers a
// waker. A snapshot taken after that drop would be false and skip the
// self-wake below, leaving the connection pending without closing.
let had_streams_or_refs = self.inner.has_streams_or_other_references();
self.inner.maybe_close_connection_if_no_streams();
let result = self.inner.poll(cx).map_err(Into::into);
// if we had streams/refs, and don't anymore, wake up one more time to
// ensure proper shutdown
Expand Down