Skip to content

Commit

Permalink
Use accept4(2) on NetBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed Apr 25, 2020
1 parent ab781a0 commit 4e306ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extra-docs = []
log = "0.4.8"

[target.'cfg(unix)'.dependencies]
libc = "0.2.62"
libc = "0.2.69"

[target.'cfg(windows)'.dependencies]
miow = "0.3.3"
Expand Down
10 changes: 2 additions & 8 deletions src/sys/unix/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, Socket
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
))]
let stream = {
Expand All @@ -77,14 +78,7 @@ pub fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, Socket
// But not all platforms have the `accept4(2)` call. Luckily BSD (derived)
// OSes inherit the non-blocking flag from the listener, so we just have to
// set `CLOEXEC`.
#[cfg(any(
target_os = "ios",
target_os = "macos",
// NetBSD 8.0 actually has `accept4(2)`, but libc doesn't expose it
// (yet). See https://github.com/rust-lang/libc/issues/1636.
target_os = "netbsd",
target_os = "solaris",
))]
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "solaris"))]
let stream = {
syscall!(accept(
listener.as_raw_fd(),
Expand Down

0 comments on commit 4e306ad

Please sign in to comment.