Don't panic in WorkController::drop

async
Manos Pitsidianakis 2020-02-28 09:12:36 +02:00
parent 6b2a1f7757
commit 7b631beb0a
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 5 additions and 3 deletions

View File

@ -220,7 +220,7 @@ impl Drop for State {
use nix::sys::wait::{waitpid, WaitPidFlag};
/* Try wait, we don't want to block */
if let Err(e) = waitpid(child_pid, Some(WaitPidFlag::WNOHANG)) {
eprintln!("Failed to wait on subprocess {}: {}", child_pid, e);
debug!("Failed to wait on subprocess {}: {}", child_pid, e);
}
}
}

View File

@ -64,8 +64,10 @@ pub struct WorkController {
impl Drop for WorkController {
fn drop(&mut self) {
for _ in 0..self.threads.lock().unwrap().len() {
self.thread_end_tx.send(true).unwrap();
if let Ok(lock) = self.threads.lock() {
for _ in 0..lock.len() {
let _ = self.thread_end_tx.send(true);
}
}
}
}