File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
library/std/src/sys_common Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -398,13 +398,20 @@ impl TcpListener {
398398 let ( addrp, len) = addr. into_inner ( ) ;
399399 cvt ( unsafe { c:: bind ( sock. as_raw ( ) , addrp, len as _ ) } ) ?;
400400
401- // Start listening
402- #[ cfg( not( target_os = "horizon" ) ) ]
403- cvt ( unsafe { c:: listen ( sock. as_raw ( ) , 128 ) } ) ?;
404- // 40 is the maximum for Horizon OS
405- #[ cfg( target_os = "horizon" ) ]
406- cvt ( unsafe { c:: listen ( sock. as_raw ( ) , 40 ) } ) ?;
401+ cfg_if:: cfg_if! {
402+ if #[ cfg( target_os = "horizon" ) ] {
403+ // The 3DS doesn't support a big connection backlog. Sometimes
404+ // it allows up to about 37, but other times it doesn't even
405+ // accept 32. There may be a global limitation causing this.
406+ let backlog = 20 ;
407+ } else {
408+ // The default for all other platforms
409+ let backlog = 128 ;
410+ }
411+ }
407412
413+ // Start listening
414+ cvt ( unsafe { c:: listen ( sock. as_raw ( ) , backlog) } ) ?;
408415 Ok ( TcpListener { inner : sock } )
409416 }
410417
You can’t perform that action at this time.
0 commit comments