fix(libSceNet): report EAGAIN when a datagram receive times out on Windows #4092
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4092"
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 EagleBearerYS on 2026-10-11T23:05:24Z.
What
With
SO_RCVTIMEOset, a receive on a datagram socket that waits that long fails on Windows withETIMEDOUT(0x8041013C, errno 60): Winsock reportsWSAETIMEDOUTandnative_errormaps it to 60. FreeBSD returnsEWOULDBLOCK(35):sbwaitsleeps with the socket buffer'ssb_timeo,msleep_sbtreturnsEWOULDBLOCKwhen it expires,soreceivepasses that on andkern_recvitkeeps it when nothing was received (uipc_sockbuf.c, uipc_syscalls.c). Linux returnsEAGAIN, and POSIX (XSH section 2.10.16,SO_RCVTIMEO) requiresEAGAINorEWOULDBLOCKwhen no data was received.A datagram socket has no connection that can time out (an ICMP port unreachable arrives as
WSAECONNRESET), so on such a socketWSAETIMEDOUTonly means that the receive timeout the guest set has expired.sceNetRecv,sceNetRecvfromandsceNetRecvmsgnow reportEAGAINin that case, and only when the socket has a receive timeout.Stream sockets and
SO_SNDTIMEOkeepETIMEDOUT; the new TechnicalDebt entry records them. On a connectionWSAETIMEDOUTcan also be a real connection timeout, Winsock documents the connection as indeterminate afterSO_RCVTIMEOorSO_SNDTIMEOexpire (SOL_SOCKET options), and a timed-out send reports no partial count (a blocking loopback TCP send with a 50 msSO_SNDTIMEOfails after 59 ms with no count). FreeBSD's behaviour there needs the timeout waited for without the host option, which is a separate change.Windows, 50 ms
SO_RCVTIMEO, nothing queued:mainsceNetRecv,sceNetRecvfrom,sceNetRecvmsg0x8041013C, errno 600x80410123, errno 35, as on LinuxsceNetRecv0x8041013C, errno 60Tested
Windows 11 (10.0.26300), MinGW-w64 GCC 15.2.0 (WinLibs r7, UCRT), Release,
BUILD_TESTING=ON, onmainat325e0a8bwith #4021 applied locally, sincemain's Windows build stops inSocket.cppwithout it:guest_sce_net: the newCheckReceiveTimeoutsets a 50 ms receive timeout on the UDP receiver;sceNetRecv,sceNetRecvfromandsceNetRecvmsgwith nothing queued fail withEAGAIN, and a datagram sent afterwards is still received. Aborts onmainat the first receive (0x8041013C), passes with the change; 20 more runs pass. The whole test takes 0.3 s.core/libs/prx/libc/CMakeLists.txtandcore/libs/prx/libkernel/CMakeLists.txtthat build on Windows pass, as doguest_resolverandguest_posix_filesystem(libScePosixForWebKit, which links libSceNet).tools/check_conventions.py --base origin/mainpasses.#ifdef _WIN32; Linux already returnsEAGAINfor an expiredSO_RCVTIMEO, which the new checks expect.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (none added).mdfiles or images added to the repository (attach them to this PR)