Skip to content

Commit

Permalink
fix: busy loop on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jan 20, 2025
1 parent b109803 commit 7e25f61
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,11 @@ where

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.inner.maybe_close_connection_if_no_streams();
let had_streams_or_refs = self.inner.has_streams_or_other_references();
let result = self.inner.poll(cx).map_err(Into::into);
if result.is_pending() && !self.inner.has_streams_or_other_references() {
// if we had streams/refs, and don't anymore, wake up one more time to
// ensure proper shutdown
if result.is_pending() && had_streams_or_refs && !self.inner.has_streams_or_other_references() {
tracing::trace!("last stream closed during poll, wake again");
cx.waker().wake_by_ref();
}
Expand Down

0 comments on commit 7e25f61

Please sign in to comment.