From 62f55043a503d88c0990fb46bbf90f5fa5d54645 Mon Sep 17 00:00:00 2001 From: StNicolay Date: Sun, 11 Aug 2024 11:37:51 +0300 Subject: [PATCH] Small optimization for non unix targets --- src/main.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 62823fc..3e96a82 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,20 +85,21 @@ async fn shutdown_signal() { }; #[cfg(unix)] - let terminate = async { - signal::unix::signal(signal::unix::SignalKind::terminate()) - .expect("failed to install signal handler") - .recv() - .await; - }; + { + let terminate = async { + signal::unix::signal(signal::unix::SignalKind::terminate()) + .expect("failed to install signal handler") + .recv() + .await; + }; + tokio::select! { + () = ctrl_c => {} + () = terminate => {} + } + } #[cfg(not(unix))] - let terminate = std::future::pending::<()>(); - - tokio::select! { - () = ctrl_c => {}, - () = terminate => {}, - } + ctrl_c.await; } fn app(state: AppState) -> Router {