about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2024-01-13 20:04:47 +0000
committerDavid Carlier <devnexen@gmail.com>2024-01-15 07:26:19 +0000
commit89cf17777bd3e1ebb15cc6e85cbcbd955bf12252 (patch)
tree166d52603d03d52b4377a70bd5ff91f355e2c815
parent9567c3ee73e78e5395a0d4aafce915cb7d7e883f (diff)
downloadrust-89cf17777bd3e1ebb15cc6e85cbcbd955bf12252.tar.gz
rust-89cf17777bd3e1ebb15cc6e85cbcbd955bf12252.zip
std::net: bind update for using backlog as `-1` too.
Albeit not documented, macOs also support negative value for the backlog
argument.

ref: https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/kern/uipc_socket.c#L1061
-rw-r--r--library/std/src/os/unix/net/listener.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/library/std/src/os/unix/net/listener.rs b/library/std/src/os/unix/net/listener.rs
index 8bf1e2dca6f..ecc0bbce543 100644
--- a/library/std/src/os/unix/net/listener.rs
+++ b/library/std/src/os/unix/net/listener.rs
@@ -80,7 +80,12 @@ impl UnixListener {
                 target_os = "horizon"
             ))]
             const backlog: libc::c_int = 128;
-            #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
+            #[cfg(any(
+                target_os = "linux",
+                target_os = "freebsd",
+                target_os = "openbsd",
+                target_os = "macos"
+            ))]
             const backlog: libc::c_int = -1;
             #[cfg(not(any(
                 target_os = "windows",
@@ -88,6 +93,7 @@ impl UnixListener {
                 target_os = "linux",
                 target_os = "freebsd",
                 target_os = "openbsd",
+                target_os = "macos",
                 target_os = "espidf",
                 target_os = "horizon"
             )))]