未验证 提交 be8b88f2 编写于 作者: A AzureMarker 提交者: Mark Drobnak

Lower listen backlog to fix accept crashes

See https://github.com/Meziu/rust-horizon/pull/1
上级 4e808f87
......@@ -398,13 +398,20 @@ pub fn bind(addr: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
let (addrp, len) = addr.into_inner();
cvt(unsafe { c::bind(sock.as_raw(), addrp, len as _) })?;
// Start listening
#[cfg(not(target_os = "horizon"))]
cvt(unsafe { c::listen(sock.as_raw(), 128) })?;
// 40 is the maximum for Horizon OS
#[cfg(target_os = "horizon")]
cvt(unsafe { c::listen(sock.as_raw(), 40) })?;
cfg_if::cfg_if! {
if #[cfg(target_os = "horizon")] {
// The 3DS doesn't support a big connection backlog. Sometimes
// it allows up to about 37, but other times it doesn't even
// accept 32. There may be a global limitation causing this.
let backlog = 20;
} else {
// The default for all other platforms
let backlog = 128;
}
}
// Start listening
cvt(unsafe { c::listen(sock.as_raw(), backlog) })?;
Ok(TcpListener { inner: sock })
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册