diff --git a/src/plugin/directory.rs b/src/plugin/directory.rs index a3a284e2..cd3f7c08 100644 --- a/src/plugin/directory.rs +++ b/src/plugin/directory.rs @@ -30,7 +30,10 @@ use humantime::parse_duration; use once_cell::sync::Lazy; use pingora::proxy::Session; use std::fs::Metadata; +#[cfg(unix)] use std::os::unix::fs::MetadataExt; +#[cfg(windows)] +use std::os::windows::fs::MetadataExt; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::time::UNIX_EPOCH; @@ -390,7 +393,11 @@ mod tests { use crate::{config::PluginConf, config::PluginStep, plugin::Plugin}; use pingora::proxy::Session; use pretty_assertions::{assert_eq, assert_ne}; - use std::{os::unix::fs::MetadataExt, path::Path}; + #[cfg(unix)] + use std::os::unix::fs::MetadataExt; + #[cfg(windows)] + use std::os::windows::fs::MetadataExt; + use std::path::Path; use tokio_test::io::Builder; #[test] diff --git a/src/proxy/server.rs b/src/proxy/server.rs index 3d5fa483..05cd9a17 100644 --- a/src/proxy/server.rs +++ b/src/proxy/server.rs @@ -613,7 +613,8 @@ impl ProxyHttp for Server { _session: &mut Session, reused: bool, peer: &HttpPeer, - _fd: std::os::unix::io::RawFd, + #[cfg(unix)] _fd: std::os::unix::io::RawFd, + #[cfg(windows)] _sock: std::os::windows::io::RawSocket, digest: Option<&Digest>, ctx: &mut Self::CTX, ) -> pingora::Result<()> diff --git a/src/state/process.rs b/src/state/process.rs index 3f70ee65..f0e539d4 100644 --- a/src/state/process.rs +++ b/src/state/process.rs @@ -139,6 +139,7 @@ static PROCESS_RESTAR_COUNT: Lazy = Lazy::new(|| AtomicU8::new(0)); static PROCESS_RESTARTING: Lazy = Lazy::new(|| AtomicBool::new(false)); +#[cfg(unix)] pub fn restart_now() -> io::Result { let restarting = PROCESS_RESTARTING.swap(true, Ordering::Relaxed); if restarting { @@ -167,6 +168,13 @@ pub fn restart_now() -> io::Result { )) } } +#[cfg(windows)] +pub fn restart_now() -> io::Result { + return Err(io::Error::new( + io::ErrorKind::Other, + "Not support restart".to_string(), + )); +} pub fn restart() { let count = PROCESS_RESTAR_COUNT.fetch_add(1, Ordering::Relaxed) + 1;