Skip to content

Commit 8dc26ad

Browse files
authored
fix: busy loop on shutdown (#834)
When in a slow shutdown, this was busy looping since no more streams were left. The change here now only makes sure we poll one extra time if the state changed during the poll. Fixes #831
1 parent b109803 commit 8dc26ad

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/client.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1437,8 +1437,14 @@ where
14371437

14381438
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
14391439
self.inner.maybe_close_connection_if_no_streams();
1440+
let had_streams_or_refs = self.inner.has_streams_or_other_references();
14401441
let result = self.inner.poll(cx).map_err(Into::into);
1441-
if result.is_pending() && !self.inner.has_streams_or_other_references() {
1442+
// if we had streams/refs, and don't anymore, wake up one more time to
1443+
// ensure proper shutdown
1444+
if result.is_pending()
1445+
&& had_streams_or_refs
1446+
&& !self.inner.has_streams_or_other_references()
1447+
{
14421448
tracing::trace!("last stream closed during poll, wake again");
14431449
cx.waker().wake_by_ref();
14441450
}

0 commit comments

Comments
 (0)