fix(libkernel): report a stream whose peer closed as readable in poll on Windows #8483
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8483"
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 xXPBSXx on 2026-10-20T13:27:47Z.
What
WSAPollreportsPOLLHUPalone for a stream socket whose peer has closed, whether or not the socket's own sending side is shut.pollpassed that on, so on Windows such a socket never came back asPOLLIN. FreeBSD'ssopoll_genericreports a socket that can receive no more as readable and addsPOLLHUPonly once it can send no more either (Linux'spollalready does this). On Windows, a guest stream socket'sPOLLHUPwithoutPOLLERRnow also reports the read bit that was asked for, and keepsPOLLHUPonly aftershutdownhas shut the socket's own sending side (Socket::sendShut). A reset or refused connection (POLLHUPwithPOLLERR) and libSceNet sockets keepWSAPoll's flags. A new Technical debt entry says so.Fixes #8482
Overlap:
git merge-treeagainst the open socket PRs #7090, #8392, #8448, #8463, #8474, #7511, #7850, #7490 and #8312 is clean.pr_overlapwas not run.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main
3cde166e45+ this commit:guest_poll: the new case aborts without the change toUdp.cppand passes with it. It checksPOLLIN,POLLIN|POLLOUT,POLLRDNORMandPOLLOUTalone after the peer'sshutdown(SHUT_WR)(noPOLLHUP),recvreturning 0, andPOLLIN|POLLHUPon both ends once the other side has shut its sending side too.guest_sce_net,guest_socket_error,guest_udp,guest_select,guest_select_wait,guest_tcp,guest_socket_pairandguest_recvmsg_memorypass.python tools/check_conventions.py --base upstream/main: passes.poll(guest_socket_descriptors,guest_socket_options) were not rerun by me for this change; theirpollcalls do not involve a peer that closed.closeby the peer with unread data.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T13:47:08Z.
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.mdL201docs/dev/debt/libkernel.mdL189core/libs/prx/libkernel/Socket/src/Udp.cppL540docs/dev/debt/libkernel.mdL189core/libs/tests/GuestPoll.cppL214, L216docs/dev/debt/libkernel.mdL201Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdcore/libs/tests/GuestPoll.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/tests/GuestPoll.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T14:26:20Z.
Thanks, this matches
sopoll_genericfor a TCP peer that closed. One follow-up indocs/dev/debt/libkernel.md: thesocketpairentry still says "On Windowspollon a stream end reportsPOLLHUPwithoutPOLLINafter the peer'sshutdown(SHUT_WR)orclose". With this change that's no longer true, since a socketpair stream end is a loopback TCP connection on Windows. The remaining gap is narrower. After the peer'sclose, FreeBSD'sunp_dropdisconnects the other end, so the console reportsPOLLIN | POLLHUP, while Windows now reportsPOLLINalone (the end hasn't shut its own sending side). Could you update that sentence to describe what's left?Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T14:59:46Z.
Fixed in ab21d78896: the socketpair entry in docs/dev/debt/libkernel.md now says that a pair end reports POLLIN after the peer's shutdown(SHUT_WR) or close on Windows; the remaining gap is that after close the console also reports POLLHUP (unp_drop disconnects the other end), which the loopback connection cannot tell from a shutdown, so no POLLHUP is reported. Docs only; no code change.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-21T09:27:14Z.
Linux follow-up validation of exact PR head
ab21d78896d2db26706fe03c195466f0ca78540f: all 11 selected poll/socket tests passed three consecutive executions each (33 successful executions, no failures or skips).Environment: Debian 13.7 x86-64, Linux
7.2.9-x64v3-xanmod1, AMD Ryzen 5 7640HS, GCC 15.2.0, CMake 3.31.6, Release,BUILD_TESTING=ON,ANYPS5_RELINKER_ONLY=OFF, bundled dependencies. Configured the full project in an isolated checkout and builtlibkernel, the selected test executables, and their dependencies with two jobs. Tracked source files remained unchanged.guest_pollpassed the newPollsAStreamWhosePeerClosedregression: after the peer'sshutdown(SHUT_WR), exact results werePOLLIN,POLLIN|POLLOUT,POLLRDNORM, orPOLLOUTaccording to the requested mask, with noPOLLHUP;recvreturned 0; after both sending sides were shut, both ends reportedPOLLIN|POLLHUP. The complete test took about 0.30 s per execution.guest_socket_descriptorsandguest_socket_optionstests, listed as not rerun in the PR description, also passed all three executions on Linux.guest_sce_net,guest_socket_error,guest_udp,guest_select,guest_select_wait,guest_tcp,guest_socket_pair, andguest_recvmsg_memory.Command:
The production fix is Windows-only, so this adds Linux coverage for the shared regression and surrounding socket behavior. No new Windows run, macOS, PS5 hardware, title, GPU, or full repository test-suite validation was performed.
AI-assisted testing and report.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T23:23:05Z.
@xXPBSXx a heads-up: #9492 makes the same change to
poll. It's #5403, first opened on 2026-10-13 and closed on 10-14 for having no title, now open again. Either can go in; the other then closes.