]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys_common/net.rs
Rollup merge of #96173 - jmaargh:jmaargh/with-capacity-doc-fix, r=Dylan-DPC
[rust.git] / library / std / src / sys_common / net.rs
index 05425f4a3622ce04167f4df5dca684774bfd17ce..f5730a2cea52b5b4c469428f8fe156990b66c9bc 100644 (file)
@@ -398,8 +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 _) })?;
 
+        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(), 128) })?;
+        cvt(unsafe { c::listen(sock.as_raw(), backlog) })?;
         Ok(TcpListener { inner: sock })
     }