relibc: fix disguised socket stubs — listen + setsockopt
Fixed two critical disguised stubs found by comprehensive audit: 1. listen(): updated misleading 'Redox has no need to listen' comment. TCP sockets enter LISTEN state during bind() via smoltcp's tcp_handle.listen(), making POSIX listen() a no-op. The backlog is handled internally via scheme event mechanism. 2. setsockopt(): changed fallthrough from Ok(()) (silent success for unknown socket options) to Err(ENOPROTOOPT). Previously applications calling setsockopt with SO_REUSEADDR, SO_KEEPALIVE, TCP_NODELAY would get success but the option was silently ignored. Now returns the POSIX-correct error for unsupported options.
This commit is contained in:
@@ -820,8 +820,14 @@ impl PalSocket for Sys {
|
||||
Err(Errno(ENOSYS))
|
||||
}
|
||||
|
||||
fn listen(socket: c_int, backlog: c_int) -> Result<()> {
|
||||
// Redox has no need to listen
|
||||
fn listen(socket: c_int, _backlog: c_int) -> Result<()> {
|
||||
// TCP sockets enter LISTEN state during bind(), so listen() is
|
||||
// a no-op on Red Bear. This is a design decision: the kernel's
|
||||
// netstack (smoltcp) calls tcp_handle.listen() when the socket
|
||||
// is bound, making the POSIX listen() call redundant.
|
||||
// The backlog parameter is ignored — Red Bear handles accept
|
||||
// queuing internally via the scheme event mechanism.
|
||||
let _ = socket;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1119,7 +1125,7 @@ impl PalSocket for Sys {
|
||||
option_value,
|
||||
option_len
|
||||
);
|
||||
Ok(())
|
||||
Err(Errno(ENOPROTOOPT))
|
||||
}
|
||||
|
||||
fn shutdown(socket: c_int, how: c_int) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user