Prepare for 2024 edition
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
parent
cb01d445f1
commit
715ef8c021
3 changed files with 21 additions and 14 deletions
27
src/lib.rs
27
src/lib.rs
|
@ -843,17 +843,19 @@ pub fn register_cancel_handler() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe extern "C" fn cancel_handler(_: libc::c_int) {
|
unsafe extern "C" fn cancel_handler(_: libc::c_int) {
|
||||||
let strikes = STRIKES.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
unsafe {
|
||||||
log::error!(
|
let strikes = STRIKES.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||||
"Thread blocked for too long, force pthread_exit() (strikes: {}/{})",
|
log::error!(
|
||||||
strikes,
|
"Thread blocked for too long, force pthread_exit() (strikes: {}/{})",
|
||||||
5
|
strikes,
|
||||||
);
|
5
|
||||||
if strikes == 5 {
|
);
|
||||||
log::error!("Too many strikes, exiting");
|
if strikes == 5 {
|
||||||
estop();
|
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 {
|
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)]
|
#[cfg_attr(feature = "cf-worker", worker::send)]
|
||||||
pub async fn index(State(state): State<Arc<AppState<Upstream, S>>>) -> Response {
|
pub async fn index(State(state): State<Arc<AppState<Upstream, S>>>) -> Response {
|
||||||
match &state.clone().config.index_redirect {
|
match &state.clone().config.index_redirect {
|
||||||
IndexConfig::Redirect { permanent, ref url } => {
|
&IndexConfig::Redirect {
|
||||||
|
ref permanent,
|
||||||
|
ref url,
|
||||||
|
} => {
|
||||||
if *permanent {
|
if *permanent {
|
||||||
Redirect::permanent(url).into_response()
|
Redirect::permanent(url).into_response()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,7 +59,7 @@ fn interrupt() -> mpsc::Receiver<()> {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if std::env::var("RUST_LOG").is_err() {
|
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();
|
env_logger::init();
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,15 @@ pub struct Instant(std::time::Instant);
|
||||||
impl Instant {
|
impl Instant {
|
||||||
/// Create a new `Instant` from the current time
|
/// Create a new `Instant` from the current time
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[must_use] pub fn now() -> Self {
|
#[must_use]
|
||||||
|
pub fn now() -> Self {
|
||||||
Self(std::time::Instant::now())
|
Self(std::time::Instant::now())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the elapsed time since the instant was created
|
/// Get the elapsed time since the instant was created
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[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()
|
self.0.elapsed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue