fix(libSceNet): report EAGAIN when a stream send or receive times out on Windows #4758
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4758"
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-12T20:57:23Z.
What
SO_RCVTIMEOandSO_SNDTIMEOon a libSceNet socket are set as the host socket's timeouts. On Windows a blocking receive or send on a stream socket that times out then fails withETIMEDOUT(0x8041013c), where FreeBSD 11.4 returnsEAGAIN:sbwait()sleeps for the buffer'ssb_timeoand returnsEWOULDBLOCKwhen it runs out;soreceive_generic()andsosend_generic()return that error;kern_sendit()returns the partial count instead when part of the data was sent.Winsock reports its own timeout as
WSAETIMEDOUTwith no partial count, and documents that the connection is then in an indeterminate state (SOL_SOCKET options). #4092 fixed the datagram case, where the host timeout is safe. The stream case was left in TechnicalDebt for this reason.On Windows, a blocking
sceNetRecv,sceNetRecvfrom,sceNetRecvmsg,sceNetSendorsceNetSendto(and sosceNetSendmsg) on a stream socket with a timeout now waits for the socket withWSAPollfor that timeout first. It fails withEAGAINwhen the wait ends, so the host timeout does not fire and the connection stays usable. A zero-length transfer does not wait, as insoreceive_generic().A socket the host reports as unconnected (
getpeernamefails) does not wait either, becauseWSAPollreports no event for it until the timeout. This covers a never-connected socket and a listening one, so their receive still fails at once withENOTCONN.The host option stays set for one case: a receive whose data another thread takes between the wait and the receive. That timeout now also maps to
EAGAINfor stream sockets.Linux and macOS are unchanged; their host timeouts already behave as FreeBSD's. The TechnicalDebt entry is rewritten. What remains is a send that starts while the socket is writable and still blocks past the timeout: it fails with
ETIMEDOUT, where FreeBSD returns the partial count. No title is claimed.The dependencies on #4669 and #4673 are only about merge order. They change the lines next to this change: the libSceNet TechnicalDebt entry above it, and
sceNetSend's send call. This branch follows them once they merge.Tested
Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release,
-DBUILD_TESTING=ON, onmainatc952c2b0e:CheckStreamTimeoutsinguest_sce_net, on a connected loopback TCP pair:SO_RCVTIMEO,sceNetRecv(without and withMSG_PEEK),sceNetRecvfromandsceNetRecvmsgfail withEAGAINafter at least 40 ms. Data sent afterwards still arrives.sceNetRecvon a never-connected socket and on the listening socket, both with the same timeout, fails withENOTCONN.SO_SNDBUFand a 50 msSO_SNDTIMEO, 64 KiB sends to a peer that does not read succeed until one fails withEAGAINafter at least 40 ms.main'sExport.cpp, the test aborts at the first timed-outsceNetRecv, which fails with0x8041013c(ETIMEDOUT) after 50 ms.EAGAIN, but the send that fills the peer fails withETIMEDOUTafter 49 ms, 393216 bytes in.getpeernamecheck, the receive on the unconnected socket waits and fails withEAGAIN.guest_sce_netpasses 20 runs in a row.guest_sce_net,guest_memory_pool_stats,guest_resolver, theguest_datagram_*andguest_socket_host_write_*tests, and the tests registered incore/libs/prx/libc/CMakeLists.txtandcore/libs/prx/libkernel/CMakeLists.txtthat build on Windows.tools/check_conventions.py --base origin/mainpasses.-DANYPS5_ENABLE_SPIRV_TOOLS=ON), on the same commit.guest_sce_net, includingCheckStreamTimeouts, passes 20 runs in a row. The code change does not apply there; the test checks that Linux's own timeouts already giveEAGAIN, the sent count andENOTCONN.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T00:10:06Z.
Windows test: head
0a1c30d58merged onto currentmain43e3a70f8(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filterguest_sce_net: guest_sce_net passed (1 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T07:29:57Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libSceNet.mdL11Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:38:19Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed