From b1993421c20085d25afa9cf04daa36aea6040540 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Thu, 15 Jul 2021 18:09:10 +0200 Subject: [PATCH] fix signal compiling on windows --- src/database.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/database.rs b/src/database.rs index c39f0fb..2d7886e 100644 --- a/src/database.rs +++ b/src/database.rs @@ -543,11 +543,10 @@ impl Database { #[cfg(feature = "sqlite")] pub async fn start_wal_clean_task(lock: &Arc>, config: &Config) { - use tokio::{ - select, - signal::unix::{signal, SignalKind}, - time::{interval, timeout}, - }; + use tokio::time::{interval, timeout}; + + #[cfg(unix)] + use tokio::signal::unix::{signal, SignalKind}; use std::{ sync::Weak, @@ -562,10 +561,12 @@ impl Database { tokio::spawn(async move { let mut i = interval(timer_interval); + #[cfg(unix)] let mut s = signal(SignalKind::hangup()).unwrap(); loop { - select! { + #[cfg(unix)] + tokio::select! { _ = i.tick(), if do_timer => { log::info!(target: "wal-trunc", "Timer ticked") } @@ -573,7 +574,14 @@ impl Database { log::info!(target: "wal-trunc", "Received SIGHUP") } }; - + #[cfg(not(unix))] + if do_timer { + i.tick().await; + log::info!(target: "wal-trunc", "Timer ticked") + } else { + // timer disabled, and there's no concept of signals on windows, bailing... + return; + } if let Some(arc) = Weak::upgrade(&weak) { log::info!(target: "wal-trunc", "Rotating sync helpers..."); // This actually creates a very small race condition between firing this and trying to acquire the subsequent write lock.