Skip to content

Commit 743eb65

Browse files
committed
std::net::bind using -1 for openbsd which in turn sets it to somaxconn.
trusting platform's SOMAXCONN instead of hardcoding to 128 otherwise.
1 parent 51c0db6 commit 743eb65

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,15 @@ impl UnixListener {
7474
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
7575
let (addr, len) = sockaddr_un(path.as_ref())?;
7676
const backlog: libc::c_int =
77-
if cfg!(any(target_os = "linux", target_os = "freebsd")) { -1 } else { 128 };
77+
if cfg!(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")) {
78+
-1
79+
} else if cfg!(target_os = "redox") {
80+
// redox's relibc defines as 128
81+
// FIXME: adding to libc's crate
82+
128
83+
} else {
84+
libc::SOMAXCONN
85+
};
7886

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

0 commit comments

Comments
 (0)