fix(libkernel): accept MSG_DONTWAIT in the socket send and receive calls #4676
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4676"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-12T18:34:43Z.
What
libkernel's
send,sendto,sendmsg,recv,recvfromandrecvmsgfailed withEOPNOTSUPPforMSG_DONTWAIT(0x80), so code that polls a blocking socket with it, as POSIX networking code and the libraries homebrew ports bring along commonly do, got an error on every call instead of its data orEWOULDBLOCK.FreeBSD 11.4 defines the flag in
sys/sys/socket.h:and
soreceive_generic()(sys/kern/uipc_socket.c) treats it as a non-blocking socket for that one call:On Linux and macOS the flag now maps to the host's
MSG_DONTWAIT, next toMSG_PEEKon a receive andMSG_NOSIGNALon a send, so the call returns at once with the data orEAGAINand the socket itself stays blocking. Winsock has no per-call non-blocking flag, so on Windows these calls still fail withEOPNOTSUPPfor it; a TechnicalDebt entry records that. Other flags still fail withEOPNOTSUPP. #4673 is the same change for libSceNet.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on
main5d933db0.guest_udpgainedCheckDontWaiton a blocking UDP socket: with nothing queued,recv,recvfrom,recvmsgandMSG_DONTWAIT | MSG_PEEKfail withEAGAIN, all within one second; a datagram sent withsendto(..., MSG_DONTWAIT)is peeked withMSG_DONTWAIT | MSG_PEEKand then read withMSG_DONTWAIT;send(..., MSG_DONTWAIT | MSG_NOSIGNAL)on a connected socket delivers;MSG_OOBstill fails withEOPNOTSUPP. On Windows the test expectsEOPNOTSUPPfor the flag.main'sUdp.cppthe test aborts (EOPNOTSUPPinstead ofEAGAIN).guest_udppasses, also in 30 repeated runs; allguest_*tests exceptguest_video_out_*pass (310/310).Windows: @johnmaia ran it on Windows 11 with WinLibs GCC 15.2.0, merged into
main3faa9cb40.guest_udppasses, withCheckDontWait's Windows branch gettingEOPNOTSUPPfor the flag, and the full suite passes 1074 of 1074. Merges cleanly with #4351, #4391, #4498, #4658, #4669 and #4673.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-13T13:36:58Z.
Windows run, since the description says Windows is untested. Setup: Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,ctest -j4 --timeout 300, RTX 4080. Head7afd88926merged intomain3faa9cb40.guest_udppasses. The_WIN32branch ofCheckDontWaitruns here, sorecv,recvfrom,recvmsgandsendtowith flag0x80fail with errno 45 on Windows, as the test expects.Not tested: a title, and a negative control on Windows.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:57:53Z.
Checked
MSG_DONTWAITagainst FreeBSD'ssoreceive_generic, built and ranguest_udpplus the libkernel/libs ctest scope (147/147), and confirmedCheckDontWaitfails without theUdp.cppchange. Windows confirmed by @johnmaia (1074/1074). Merging.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T16:54:58Z.
The earlier full Build failed only in
guest_math, which was red onmainat the time and is unrelated to this diff (fixed by #5256, merged after that run). Windows was green,guest_udppasses locally on the current head. Merging once a fresh full Build is green.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T16:59:04Z.
Re-ran the full Build on the current
main(the previous run predated #5256, which fixed theguest_mathfailure). The diff is unchanged and unrelated to libc/math; merging once that run is green.