rust3ds / ctru-rs

Rust wrapper for libctru
https://rust3ds.github.io/ctru-rs/
Other
120 stars 18 forks source link

Missing libc::SOMAXCONN for HorizonOS #152

Closed Meziu closed 8 months ago

Meziu commented 9 months ago

Seems like the latest nightly broke something in the std::os::unix::net module, for which now the maximum backlog number for horizonOS seems to be set to libc::SOMAXCONN, a constant we obviously do not include. This is the referred line.

We already had problems in the past that made us set the maximum backlog number to 20 for std::sys_common::net (right here), but I guess no action was taken for UnixListener.

To be completely honest, I don't know whether horizon supports UnixListener fully, but this might be a chance to add a new const to libc that might be used by external crates. Otherwise, we can simply add a #[cfg(target_os = "horizon")] and set our own value within std. In the mean time, the CI fails on the latest nightly. :(

ian-h-chamberlain commented 9 months ago

The only references I can find in newlib look to be for unrelated platforms: https://github.com/search?q=repo%3AdevkitPro%2Fnewlib%20SOMAXCONN&type=code

I did find one comment that the libctru maintainers consider their socket implementation to be "BSD-flavored": https://github.com/devkitPro/3ds-examples/blob/ee2e047049f6962a1deab26779e66f521302ab02/network/sockets/source/sockets.c#L86 So maybe in general we should piggypack onto cfgs like BSD?

I don't believe the 3DS supports unix sockets at all, given there is no AF_UNIX defined in libctru/include/sys/socket.h, so the actual implementation probably doesn't matter much — we could either define an arbitrary SOMAXCONN = 20 in libc, or set const backlog: libc::c_int = 128 or something in std upstream, just to get it to compile. Any thoughts?

Meziu commented 9 months ago

I don't believe the 3DS supports unix sockets at all, given there is no AF_UNIX defined in libctru/include/sys/socket.h

Well then, I’ve looked around and it seems like nobody else uses that constant for “generic” socket implementations (such as async/IO crates or std reimplementations). Since we don’t support UnixSockets, I guess a PR to the std would be much quicker.

Meziu commented 9 months ago

Opened https://github.com/rust-lang/rust/pull/119742

Meziu commented 8 months ago

Fixed as of the latest nightly.