Skip to content

Commit

Permalink
Rollup merge of rust-lang#119026 - devnexen:listener_upd, r=Mark-Simu…
Browse files Browse the repository at this point in the history
…lacrum

std::net::bind using -1 for openbsd which in turn sets it to somaxconn.

trusting platform's SOMAXCONN instead of hardcoding to 128 otherwise.
  • Loading branch information
compiler-errors committed Dec 19, 2023
2 parents 57ad505 + f5c3967 commit b1a4194
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/std/src/os/unix/net/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ impl UnixListener {
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
let (addr, len) = sockaddr_un(path.as_ref())?;
const backlog: libc::c_int =
if cfg!(any(target_os = "linux", target_os = "freebsd")) { -1 } else { 128 };
if cfg!(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")) {
-1
} else {
libc::SOMAXCONN
};

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

0 comments on commit b1a4194

Please sign in to comment.