Skip to content

Commit

Permalink
channel: Return PostAction::Remove on disconnect
Browse files Browse the repository at this point in the history
It seems 86c6713 broke this. By maintaining a copy of `Ping`, the ping
source will never return `PostAction::Remove`.
  • Loading branch information
ids1024 authored and notgull committed Sep 6, 2024
1 parent 5ba1370 commit 8d11455
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/sources/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl<T> EventSource for Channel<T> {
let receiver = &self.receiver;
let capacity = self.capacity;
let mut clear_readiness = false;
let mut disconnected = false;

let action = self
.source
Expand All @@ -226,15 +227,17 @@ impl<T> EventSource for Channel<T> {
}
Err(mpsc::TryRecvError::Disconnected) => {
callback(Event::Closed, &mut ());
clear_readiness = true;
disconnected = true;
break;
}
}
}
})
.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.
Expand Down

0 comments on commit 8d11455

Please sign in to comment.