-
-
Notifications
You must be signed in to change notification settings - Fork 483
Fix platform-specific compilation for Linux-only features in unix.rs #2410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ impl UdpSocketState { | |
|
||
// mac and ios do not support IP_RECVTOS on dual-stack sockets :( | ||
// older macos versions also don't have the flag and will error out if we don't ignore it | ||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))] | ||
#[cfg(target_os = "linux")] | ||
if is_ipv4 || !io.only_v6()? { | ||
if let Err(_err) = | ||
set_socket_option(&*io, libc::IPPROTO_IP, libc::IP_RECVTOS, OPTION_ON) | ||
|
@@ -461,7 +461,10 @@ fn send(state: &UdpSocketState, io: SockRef<'_>, transmit: &Transmit<'_>) -> io: | |
} | ||
} | ||
|
||
#[cfg(not(any(apple, target_os = "openbsd", target_os = "netbsd", solarish)))] | ||
#[cfg(all( | ||
not(any(apple, target_os = "openbsd", target_os = "netbsd", solarish)), | ||
target_os = "linux" | ||
))] | ||
fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) -> io::Result<usize> { | ||
let mut names = [MaybeUninit::<libc::sockaddr_storage>::uninit(); BATCH_SIZE]; | ||
let mut ctrls = [cmsg::Aligned(MaybeUninit::<[u8; CMSG_LEN]>::uninit()); BATCH_SIZE]; | ||
|
@@ -503,6 +506,21 @@ fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) -> | |
Ok(msg_count as usize) | ||
} | ||
|
||
#[cfg(all( | ||
not(any(apple, target_os = "openbsd", target_os = "netbsd", solarish)), | ||
not(target_os = "linux") | ||
))] | ||
fn recv( | ||
Comment on lines
+509
to
+513
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which |
||
_io: SockRef<'_>, | ||
_bufs: &mut [IoSliceMut<'_>], | ||
_meta: &mut [RecvMeta], | ||
) -> io::Result<usize> { | ||
Err(io::Error::new( | ||
io::ErrorKind::Other, | ||
"recvmmsg and mmsghdr are only available on Linux. Platform-specific implementation required.", | ||
)) | ||
} | ||
|
||
#[cfg(apple_fast)] | ||
fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) -> io::Result<usize> { | ||
let mut names = [MaybeUninit::<libc::sockaddr_storage>::uninit(); BATCH_SIZE]; | ||
|
@@ -715,7 +733,7 @@ fn decode_recv( | |
ecn_bits = cmsg::decode::<u8, libc::cmsghdr>(cmsg); | ||
}, | ||
// FreeBSD uses IP_RECVTOS here, and we can be liberal because cmsgs are opt-in. | ||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))] | ||
#[cfg(target_os = "linux")] | ||
(libc::IPPROTO_IP, libc::IP_RECVTOS) => unsafe { | ||
ecn_bits = cmsg::decode::<u8, libc::cmsghdr>(cmsg); | ||
}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you describe why these changes are necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More specifically: what platform(s) are you trying to build for? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now excludes MacOS. Why is
IP_RECVTOS
not available on MacOS? Note that this works for Firefox on MacOS:https://glam.telemetry.mozilla.org/fog/probe/networking_http_3_ecn_path_capability/explore?activeBuckets=%5B%22capable%22%2C%22bleaching%22%2C%22black-hole%22%2C%22received-unsent-ect-1%22%5D&os=Darwin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct link:
https://glam.telemetry.mozilla.org/fog/probe/networking_http_3_ecn_ce_ect0_ratio_received/explore?activeBuckets=%5B%22capable%22%2C%22bleaching%22%2C%22black-hole%22%2C%22received-unsent-ect-1%22%5D&os=Darwin