Rollup merge of #100835 - devnexen:listener_followups, r=devnexen

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

FreeBSD and using system limit instead for others.
This commit is contained in:
Dylan DPC 2022-08-23 20:40:05 +05:30 committed by GitHub
commit a163659b1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,10 +73,8 @@ 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 { 128 };
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))?;