Skip to content

Commit

Permalink
some improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
shiroedev2024 committed Apr 23, 2024
1 parent 4cd2a9d commit 71d1bb7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doh/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ 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(())
}

/// 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())
}

0 comments on commit 71d1bb7

Please sign in to comment.