Skip to content

Commit 918258f

Browse files
committed
net listen backlog update, follow-up from rust-lang#97963.
FreeBSD and using system limit instead for others.
1 parent f2858b5 commit 918258f

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)