From af565b4e24f1b8e4d7f1b7224d62b8029c580496 Mon Sep 17 00:00:00 2001 From: Andrew Hauck Date: Fri, 27 Sep 2024 11:40:03 -0700 Subject: Fix all the warnings for non-linux unix --- .bleep | 2 +- pingora-core/src/protocols/l4/ext.rs | 2 +- pingora-core/src/protocols/l4/stream.rs | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.bleep b/.bleep index 5859e11..a931ea7 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -e2493b0330def4631d98161f1f0a477b440f3a85 \ No newline at end of file +089f8397486e934dbbe045085ba3648e0bb945a5 \ No newline at end of file diff --git a/pingora-core/src/protocols/l4/ext.rs b/pingora-core/src/protocols/l4/ext.rs index d3ab70d..5437198 100644 --- a/pingora-core/src/protocols/l4/ext.rs +++ b/pingora-core/src/protocols/l4/ext.rs @@ -423,7 +423,7 @@ async fn inner_connect_with Result<()>>( } .or_err(SocketError, "failed to create socket")?; - #[cfg(target_os = "linux")] + #[cfg(unix)] { ip_bind_addr_no_port(socket.as_raw_fd(), true).or_err( SocketError, diff --git a/pingora-core/src/protocols/l4/stream.rs b/pingora-core/src/protocols/l4/stream.rs index 898b3e6..30b05a0 100644 --- a/pingora-core/src/protocols/l4/stream.rs +++ b/pingora-core/src/protocols/l4/stream.rs @@ -19,6 +19,7 @@ use futures::FutureExt; use log::{debug, error}; use pingora_error::{ErrorType::*, OrErr, Result}; +#[cfg(target_os = "linux")] use std::io::IoSliceMut; #[cfg(unix)] use std::os::unix::io::AsRawFd; @@ -28,7 +29,9 @@ use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use std::time::{Duration, Instant, SystemTime}; -use tokio::io::{self, AsyncRead, AsyncWrite, AsyncWriteExt, BufStream, Interest, ReadBuf}; +#[cfg(target_os = "linux")] +use tokio::io::Interest; +use tokio::io::{self, AsyncRead, AsyncWrite, AsyncWriteExt, BufStream, ReadBuf}; use tokio::net::TcpStream; #[cfg(unix)] use tokio::net::UnixStream; @@ -148,6 +151,7 @@ struct RawStreamWrapper { /// store the last rx timestamp of the stream. pub(crate) rx_ts: Option, /// enable reading rx timestamp + #[cfg(target_os = "linux")] pub(crate) enable_rx_ts: bool, #[cfg(target_os = "linux")] /// This can be reused across multiple recvmsg calls. The cmsg buffer may @@ -161,12 +165,14 @@ impl RawStreamWrapper { RawStreamWrapper { stream, rx_ts: None, + #[cfg(target_os = "linux")] enable_rx_ts: false, #[cfg(target_os = "linux")] reusable_cmsg_space: nix::cmsg_space!(nix::sys::time::TimeSpec), } } + #[cfg(target_os = "linux")] pub fn enable_rx_ts(&mut self, enable_rx_ts: bool) { self.enable_rx_ts = enable_rx_ts; } @@ -791,6 +797,7 @@ impl AccumulatedDuration { } #[cfg(test)] +#[cfg(target_os = "linux")] mod tests { use super::*; use std::sync::Arc; -- cgit v1.2.3