From 2f398bc4c42aefb10cdbb41befd0c18c2a103d02 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 5 Sep 2024 19:11:39 -0700 Subject: [PATCH] channel: Return `PostAction::Remove` on disconnect It seems 86c6713 broke this. By maintaining a copy of `Ping`, the ping source will never return `PostAction::Remove`. --- src/sources/channel.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sources/channel.rs b/src/sources/channel.rs index c01407c9..49f439ea 100644 --- a/src/sources/channel.rs +++ b/src/sources/channel.rs @@ -211,6 +211,7 @@ impl EventSource for Channel { let receiver = &self.receiver; let capacity = self.capacity; let mut clear_readiness = false; + let mut disconnected = false; let action = self .source @@ -226,7 +227,7 @@ impl EventSource for Channel { } Err(mpsc::TryRecvError::Disconnected) => { callback(Event::Closed, &mut ()); - clear_readiness = true; + disconnected = true; break; } } @@ -234,7 +235,9 @@ impl EventSource for Channel { }) .map_err(ChannelError)?; - if clear_readiness { + if disconnected { + Ok(PostAction::Remove) + } else if clear_readiness { Ok(action) } else { // Re-notify the ping source so we can try again.