From 7e25f6125f1af0b40f8cb77bbff86de090b5f065 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 20 Jan 2025 15:45:16 -0500 Subject: [PATCH] fix: busy loop on shutdown --- src/client.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index ffeda6077..f7243c3c8 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1437,8 +1437,11 @@ where fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { 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(); }