Prepare for 2024 edition

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-23 14:14:29 -06:00
parent cb01d445f1
commit c603428975
No known key found for this signature in database
3 changed files with 22 additions and 14 deletions

View file

@ -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<C: UpstreamClient + 'static, S: Sandboxing + Send + Sync + 'static> App<C,
#[cfg_attr(feature = "cf-worker", worker::send)]
pub async fn index(State(state): State<Arc<AppState<Upstream, S>>>) -> 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 {

View file

@ -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();

View file

@ -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()
}
}