clean up closed subscribers on send
This commit is contained in:
parent
f0a849ad77
commit
1a7add9335
|
@ -15,10 +15,8 @@ pub(crate) fn ctrlc_protection(
|
|||
|
||||
ctrlc::set_handler(move || {
|
||||
ctrlc.store(true, Ordering::SeqCst);
|
||||
if let Ok(subscribers) = subscribers.lock() {
|
||||
for subscriber in subscribers.iter() {
|
||||
let _ = subscriber.send(());
|
||||
}
|
||||
if let Ok(mut subscribers) = subscribers.lock() {
|
||||
subscribers.retain(|sender| sender.send(()).is_ok());
|
||||
}
|
||||
})
|
||||
.expect("Error setting Ctrl-C handler");
|
||||
|
|
Loading…
Reference in New Issue
Block a user