fix(libkernel): report a stream whose peer closed as readable in poll on Windows #5403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5403"
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-13T18:56:37Z.
What
When the peer of a stream socket closes, Winsock's
WSAPollreportsPOLLHUPwithoutPOLLRDNORM, whether or not the socket's own sending side is shut down.pollpassed that on, so on Windows a guest socket whose peer had closed came back asPOLLHUPalone and never asPOLLIN.FreeBSD's
sopoll_genericreports a socket that can receive no more as readable, and addsPOLLHUPonly once it can send no more either. Linux'spolldoes the same, so the Linux path already behaved this way.On Windows, a stream socket's
POLLHUPwithoutPOLLERRnow reportsPOLLRDNORMwhen reading was asked for. It keepsPOLLHUPonly aftershutdownhas shut the socket's own sending side. #5376 makes the same change insceNetEpollWait.This depends on #4903, which records that state in
Socket::sendShut. The branch contains #4903's commit (2cbec36e5); the changes here are the last two commits:0804937ebis the fix and its test;ed2b2e5aaupdates thesocketpairnote indocs/dev/debt/libkernel.md. Its stream ends are loopback TCP connections, so after the peer'sshutdown(SHUT_WR)they now reportPOLLIN, as the console does. After the peer'sclosethe console also reportsPOLLHUP, which the loopback connection cannot tell apart from a shutdown.polllooks the socket up by descriptor, and only when it reports a hang-up without an error. So the change does not rely onpoll'sheldlist, which #4933 changes to cover libSceNet sockets. Under #4933, libSceNet sockets keep the flagsWSAPollreports.Unchanged:
POLLHUPwithPOLLERR) keepsWSAPoll's flags.selectalready counts a hang-up as readable.No title is claimed.
Tested
On GitHub's runners from my fork (run), comparing #4903's head (
2cbec36e5) with this change on top:-DANYPS5_ENABLE_SPIRV_TOOLS=ON.guest_pollgains three checks:POLLINpoll of the client reports nothing;POLLIN | POLLOUT;POLLINpoll reportsPOLLIN | POLLHUP.Results:
Udp.cppthe test aborts. With the change,guest_pollpasses 20 runs in a row, and every test registered undercore/libs/prx/libc(87) andcore/libs/prx/libkernel(124) passes,guest_socket_pairincluded.guest_pollpasses with #4903's code and, 20 runs in a row, with the change. The libkernel suite (121) passes. In libc (68),guest_mathfails with and without the change on #4903's base (14036cb0e).tools/check_conventions.pypasses for the three commits.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 github-actions[bot] on 2026-10-13T19:10:37Z.
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/libkernel.mdL148Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:27:23Z.
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