Skip to content

Commit

Permalink
fix: fix build for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Oct 19, 2024
1 parent 46df0d7 commit 37b6cdf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/plugin/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion src/proxy/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()>
Expand Down
8 changes: 8 additions & 0 deletions src/state/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ static PROCESS_RESTAR_COUNT: Lazy<AtomicU8> = Lazy::new(|| AtomicU8::new(0));
static PROCESS_RESTARTING: Lazy<AtomicBool> =
Lazy::new(|| AtomicBool::new(false));

#[cfg(unix)]
pub fn restart_now() -> io::Result<process::Output> {
let restarting = PROCESS_RESTARTING.swap(true, Ordering::Relaxed);
if restarting {
Expand Down Expand Up @@ -167,6 +168,13 @@ pub fn restart_now() -> io::Result<process::Output> {
))
}
}
#[cfg(windows)]
pub fn restart_now() -> io::Result<process::Output> {
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;
Expand Down

0 comments on commit 37b6cdf

Please sign in to comment.