From 9136f857ccfec7e7a58a8c95d50994e58864df36 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 1 Apr 2019 12:03:47 +0200 Subject: [PATCH] add global var to indicate server shutdown requests --- src/tools.rs | 12 ++++++++++++ src/tools/daemon.rs | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/tools.rs b/src/tools.rs index 5dabb416..52640f73 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -545,3 +545,15 @@ pub fn fd_change_cloexec(fd: RawFd, on: bool) -> Result<(), Error> { fcntl(fd, F_SETFD(flags))?; Ok(()) } + + +static mut SHUTDOWN_REQUESTED: bool = false; + +pub fn request_shutdown() { + unsafe { SHUTDOWN_REQUESTED = true; } +} + +#[inline(always)] +pub fn shutdown_requested() -> bool { + unsafe { SHUTDOWN_REQUESTED } +} diff --git a/src/tools/daemon.rs b/src/tools/daemon.rs index db66c316..eb1ead05 100644 --- a/src/tools/daemon.rs +++ b/src/tools/daemon.rs @@ -200,7 +200,10 @@ where }); Ok(service.select(signal_handler) - .map(|_| log::info!("daemon shutting down...")) - .map_err(|_| ()) + .map(|_| { + log::info!("daemon shutting down..."); + crate::tools::request_shutdown(); + }) + .map_err(|_| ()) ) }