Fix shut_down_worker_threads! in presence of panic

This commit is contained in:
Richard Feldman 2023-10-14 16:37:54 -04:00
parent 8ee88ba7cb
commit 97f252c68b
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B

View file

@ -1776,11 +1776,13 @@ fn load_multi_threaded<'a>(
macro_rules! shut_down_worker_threads {
() => {
for listener in worker_listeners {
listener.send(WorkerMsg::Shutdown).map_err(|_| {
LoadingProblem::ChannelProblem(
ChannelProblem::FailedToSendWorkerShutdownMsg,
)
})?;
// We intentionally don't propagate this Result, because even if
// shutting down a worker failed (which can happen if a a panic
// occurred on that thread), we want to continue shutting down
// the others regardless.
if listener.send(WorkerMsg::Shutdown).is_err() {
log!("There was an error trying to shutdown a worker thread. One reason this can happen is if the thread panicked.");
}
}
};
}