From c603428975e5b950f2d6815c4d9cefc19dc42805 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sat, 23 Nov 2024 14:14:29 -0600 Subject: [PATCH] Prepare for 2024 edition Signed-off-by: eternal-flame-AD --- src/lib.rs | 27 ++++++++++++++++----------- src/main.rs | 3 ++- src/timing.rs | 6 ++++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1f960a5..6274d0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -843,17 +843,19 @@ pub fn register_cancel_handler() { } } unsafe extern "C" fn cancel_handler(_: libc::c_int) { - let strikes = STRIKES.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - log::error!( - "Thread blocked for too long, force pthread_exit() (strikes: {}/{})", - strikes, - 5 - ); - if strikes == 5 { - log::error!("Too many strikes, exiting"); - estop(); + unsafe { + let strikes = STRIKES.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + log::error!( + "Thread blocked for too long, force pthread_exit() (strikes: {}/{})", + strikes, + 5 + ); + if strikes == 5 { + log::error!("Too many strikes, exiting"); + estop(); + } + libc::pthread_exit(&sandbox::EXIT_TIMEOUT as *const _ as *mut _); } - libc::pthread_exit(&sandbox::EXIT_TIMEOUT as *const _ as *mut _); } if libc::signal(libc::SIGUSR1, cancel_handler as usize) == libc::SIG_ERR { @@ -874,7 +876,10 @@ impl App>>) -> Response { match &state.clone().config.index_redirect { - IndexConfig::Redirect { permanent, ref url } => { + &IndexConfig::Redirect { + ref permanent, + ref url, + } => { if *permanent { Redirect::permanent(url).into_response() } else { diff --git a/src/main.rs b/src/main.rs index 5656285..76290a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,8 +58,9 @@ fn interrupt() -> mpsc::Receiver<()> { } fn main() { + #[allow(unsafe_code)] if std::env::var("RUST_LOG").is_err() { - std::env::set_var("RUST_LOG", "info,usvg=error"); + unsafe { std::env::set_var("RUST_LOG", "info,usvg=error") }; } env_logger::init(); diff --git a/src/timing.rs b/src/timing.rs index 38b02c2..1a19e92 100644 --- a/src/timing.rs +++ b/src/timing.rs @@ -10,13 +10,15 @@ pub struct Instant(std::time::Instant); impl Instant { /// Create a new `Instant` from the current time #[cfg(not(target_arch = "wasm32"))] - #[must_use] pub fn now() -> Self { + #[must_use] + pub fn now() -> Self { Self(std::time::Instant::now()) } /// Get the elapsed time since the instant was created #[cfg(not(target_arch = "wasm32"))] - #[must_use] pub fn elapsed(&self) -> std::time::Duration { + #[must_use] + pub fn elapsed(&self) -> std::time::Duration { self.0.elapsed() } }