mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 23:46:31 +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:
@@ -679,7 +679,21 @@ pub(crate) async fn location_loop(context: &Context, interrupt_receiver: Receive
|
||||
"Location loop is waiting for {} or interrupt",
|
||||
duration_to_str(duration)
|
||||
);
|
||||
timeout(duration, interrupt_receiver.recv()).await.ok();
|
||||
match timeout(duration, interrupt_receiver.recv()).await {
|
||||
Err(_err) => {
|
||||
info!(context, "Location loop timeout.");
|
||||
}
|
||||
Ok(Err(err)) => {
|
||||
warn!(
|
||||
context,
|
||||
"Interrupt channel closed, location loop exits now: {err:#}."
|
||||
);
|
||||
return;
|
||||
}
|
||||
Ok(Ok(())) => {
|
||||
info!(context, "Location loop received interrupt.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user