Skip to content

Commit d134a4f

Browse files
authored
Rollup merge of #119026 - devnexen:listener_upd, r=Mark-Simulacrum
std::net::bind using -1 for openbsd which in turn sets it to somaxconn. trusting platform's SOMAXCONN instead of hardcoding to 128 otherwise.
2 parents 1f32203 + ce5af1c commit d134a4f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

library/std/src/os/unix/net/listener.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,18 @@ impl UnixListener {
7373
unsafe {
7474
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
7575
let (addr, len) = sockaddr_un(path.as_ref())?;
76-
const backlog: libc::c_int =
77-
if cfg!(any(target_os = "linux", target_os = "freebsd")) { -1 } else { 128 };
76+
#[cfg(any(target_os = "windows", target_os = "redox"))]
77+
const backlog: libc::c_int = 128;
78+
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
79+
const backlog: libc::c_int = -1;
80+
#[cfg(not(any(
81+
target_os = "windows",
82+
target_os = "redox",
83+
target_os = "linux",
84+
target_os = "freebsd",
85+
target_os = "openbsd"
86+
)))]
87+
const backlog: libc::c_int = libc::SOMAXCONN;
7888

7989
cvt(libc::bind(inner.as_inner().as_raw_fd(), &addr as *const _ as *const _, len as _))?;
8090
cvt(libc::listen(inner.as_inner().as_raw_fd(), backlog))?;

0 commit comments

Comments
 (0)