Skip to content

Commit

Permalink
Rollup merge of rust-lang#100835 - devnexen:listener_followups, r=dev…
Browse files Browse the repository at this point in the history
…nexen

net listen backlog update, follow-up from rust-lang#97963.

FreeBSD and using system limit instead for others.
  • Loading branch information
Dylan-DPC authored Aug 22, 2022
2 parents 08472e5 + 918258f commit de33a44
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions library/std/src/os/unix/net/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ impl UnixListener {
unsafe {
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
let (addr, len) = sockaddr_un(path.as_ref())?;
#[cfg(target_os = "linux")]
const backlog: libc::c_int = -1;
#[cfg(not(target_os = "linux"))]
const backlog: libc::c_int = 128;
const backlog: libc::c_int = if cfg!(any(target_os = "linux", target_os = "freebsd")) {
-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 de33a44

Please sign in to comment.