mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
fix: terminate ephemeral and location loop immediately on channel close
When scheduler is destroyed, e.g. during a key import, there is some time between destroying the interrupt channel and the loop task. To avoid busy looping, tasks should terminate if receiving from the interrupt loop fails instead of treating it as the interrupt.
This commit is contained in:
@@ -569,9 +569,21 @@ pub(crate) async fn ephemeral_loop(context: &Context, interrupt_receiver: Receiv
|
||||
"Ephemeral loop waiting for deletion in {} or interrupt",
|
||||
duration_to_str(duration)
|
||||
);
|
||||
if timeout(duration, interrupt_receiver.recv()).await.is_ok() {
|
||||
// received an interruption signal, recompute waiting time (if any)
|
||||
continue;
|
||||
match timeout(duration, interrupt_receiver.recv()).await {
|
||||
Ok(Ok(())) => {
|
||||
// received an interruption signal, recompute waiting time (if any)
|
||||
continue;
|
||||
}
|
||||
Ok(Err(err)) => {
|
||||
warn!(
|
||||
context,
|
||||
"Interrupt channel closed, ephemeral loop exits now: {err:#}."
|
||||
);
|
||||
return;
|
||||
}
|
||||
Err(_err) => {
|
||||
// Timeout.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user