WebAssembly / wasi-libc

WASI libc implementation for WebAssembly
https://wasi.dev
Other
840 stars 199 forks source link

fcntl doesn't implement O_NONBLOCK for wasi:socket handles #536

Open pavelsavara opened 1 week ago

pavelsavara commented 1 week ago

fcntl doesn't implement O_NONBLOCK for wasi:socket handles

See https://github.com/WebAssembly/wasi-libc/blob/1b19fc65ad84b223876c50dd4fcd7d5a08c311dc/libc-bottom-half/cloudlibc/src/libc/fcntl/fcntl.c#L10-L61

dicej commented 1 week ago

We do already support both blocking and non-blocking sockets (e.g. https://github.com/WebAssembly/wasi-libc/blob/1b19fc65ad84b223876c50dd4fcd7d5a08c311dc/libc-bottom-half/headers/public/__header_sys_socket.h#L55 and https://github.com/WebAssembly/wasi-libc/blob/1b19fc65ad84b223876c50dd4fcd7d5a08c311dc/libc-bottom-half/sources/socket.c#L92), so presumably adding O_NONBLOCK support for toggling that should be pretty trivial.

dicej commented 5 days ago

BTW, we do already support setting FIONBIO on sockets via ioctl. I don't think there's a way to read the current state yet, though.