diff --git a/doh/src/run.rs b/doh/src/run.rs index 843ec89..5927f8c 100644 --- a/doh/src/run.rs +++ b/doh/src/run.rs @@ -68,9 +68,9 @@ pub fn run_doh(config: Config) -> DohResult<()> { pub fn shutdown_doh() -> DohResult<()> { debug!("stopping doh"); - if let Some(sender) = SHUTDOWN_SENDER.lock().unwrap().as_ref() { + let mut sender_option = SHUTDOWN_SENDER.lock().map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?; + if let Some(sender) = sender_option.take() { sender.blocking_send(()).map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; - *SHUTDOWN_SENDER.lock().unwrap() = None; } Ok(()) @@ -78,5 +78,5 @@ pub fn shutdown_doh() -> DohResult<()> { /// is running pub fn is_doh_running() -> bool { - SHUTDOWN_SENDER.lock().unwrap().as_ref().is_some() + SHUTDOWN_SENDER.lock().map_or(false, |guard| guard.is_some()) } \ No newline at end of file