From 715ef8c021c6e14b458d1d85f46b99c09e8facce 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 | 2 +- src/timing.rs | 6 ++++-- 3 files changed, 21 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..3406cd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,7 +59,7 @@ fn interrupt() -> mpsc::Receiver<()> { fn main() { 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() } }