From 3ef6fcdd9877c820468a7e59f21b72696a35bc8a Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Thu, 2 Nov 2023 16:19:13 +0800 Subject: [PATCH] try to fix build on macOS --- lib/g3-io-ext/Cargo.toml | 2 +- lib/g3-io-ext/src/udp/split.rs | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/g3-io-ext/Cargo.toml b/lib/g3-io-ext/Cargo.toml index db52eabc0..98be21e08 100644 --- a/lib/g3-io-ext/Cargo.toml +++ b/lib/g3-io-ext/Cargo.toml @@ -18,7 +18,7 @@ memchr.workspace = true fastrand.workspace = true bytes.workspace = true ahash.workspace = true -nix = { workspace = true, features = ["net"] } +nix = { workspace = true, features = ["net", "uio"] } g3-types.workspace = true g3-resolver.workspace = true diff --git a/lib/g3-io-ext/src/udp/split.rs b/lib/g3-io-ext/src/udp/split.rs index 8935a5d04..21ff270c8 100644 --- a/lib/g3-io-ext/src/udp/split.rs +++ b/lib/g3-io-ext/src/udp/split.rs @@ -94,19 +94,17 @@ impl AsyncUdpSend for SendHalf { iov: &[IoSlice<'_>], target: Option, ) -> Poll> { + #[cfg(not(target_os = "macos"))] + let flags: MsgFlags = MsgFlags::MSG_DONTWAIT | MsgFlags::MSG_NOSIGNAL; + #[cfg(target_os = "macos")] + let flags: MsgFlags = MsgFlags::MSG_DONTWAIT; + let raw_fd = self.0.as_raw_fd(); let addr = target.map(SockaddrStorage::from); loop { ready!(self.0.poll_send_ready(cx))?; if let Ok(res) = self.0.try_io(Interest::WRITABLE, || { - sendmsg( - raw_fd, - iov, - &[], - MsgFlags::MSG_DONTWAIT | MsgFlags::MSG_NOSIGNAL, - addr.as_ref(), - ) - .map_err(io::Error::from) + sendmsg(raw_fd, iov, &[], flags, addr.as_ref()).map_err(io::Error::from) }) { return Poll::Ready(Ok(res)); }