Skip to content

Commit de33a44

Browse files
authored
Rollup merge of rust-lang#100835 - devnexen:listener_followups, r=devnexen
net listen backlog update, follow-up from rust-lang#97963. FreeBSD and using system limit instead for others.
2 parents 08472e5 + 918258f commit de33a44

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ 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-
#[cfg(target_os = "linux")]
77-
const backlog: libc::c_int = -1;
78-
#[cfg(not(target_os = "linux"))]
79-
const backlog: libc::c_int = 128;
76+
const backlog: libc::c_int = if cfg!(any(target_os = "linux", target_os = "freebsd")) {
77+
-1
78+
} else {
79+
libc::SOMAXCONN
80+
};
8081

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

0 commit comments

Comments
 (0)