fix(libkernel): report a stream whose peer closed as readable in poll on Windows #9492
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9492"
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-21T23:20:09Z.
Opened again from #5403: title-less conformance fixes of this kind are merged now, for example #7365 and #8411.
What
When the peer of a stream socket closes, Winsock's
WSAPollreportsPOLLHUPwithoutPOLLRDNORM, whether or not the socket's own sending side is shut down.pollpasses that on, so on Windows a guest socket whose peer has closed comes 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 behaves this way.On Windows, a stream socket's
POLLHUPwithoutPOLLERRnow reportsPOLLRDNORMwhen reading was asked for. It keepsPOLLHUPonly aftershutdownhas shut the socket's own sending side, theSocket::sendShutstate #4903 added. The two commits:984e3b517bis the fix and its test;dd117fa25aupdates 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. A libSceNet socket waited on throughpoll(#4933) keeps the flagsWSAPollreports.Unchanged:
POLLHUPwithPOLLERR) keepsWSAPoll's flags.selectalready counts a hang-up as readable.No title is claimed.
Overlap: #8483 makes the same
pollchange, inpoll'scollectstep, with a newpolldebt entry. #5403, where this change was first opened on 2026-10-13, was closed on 10-14 for having no title. Either can go in; the other then closes.#7605 changes the same
pollloop for kqueues, next to the line this PR adds afterWSAPoll, and the two compose. Merge order: this PR goes after #7605 (merge order only) and rebases on it.Tested
On GitHub's runners from my fork, on
mainata6dcea9279(run, of the same tree as these two commits):guest_pollgains three checks:POLLINpoll of the client reports nothing;POLLIN | POLLOUT;POLLINpoll reportsPOLLIN | POLLHUP.Results:
main'sUdp.cppthe test aborts. With the change,guest_pollpasses 10 runs in a row, and every test registered undercore/libs/prx/libc(142) andcore/libs/prx/libkernel(207) passes.guest_pollpasses withmain's code and, 10 runs in a row, with the change. The libkernel suite (197) passes. In libc (115), the timing testprecise_waitfailed with and without the change in this run.tools/check_conventions.py --base origin/mainpasses for both commits.Checklist
main; #8483 makes the same change (see Overlap)NotImplemented_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 MarcZX10 on 2026-10-21T23:27:47Z.
Review: CHANGES_REQUESTED
This PR implements the same Windows
pollbehavior as the still-open #8483, and the two PRs change the sameUdp.cpppoll path. The body already identifies #8483 and says only one should go in. Please resolve that overlap with the other contributor and maintainers, then update or close one PR before this duplicate work proceeds. I have not assessed which implementation should be selected; both should not be merged.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T00:41:12Z.
Thanks, @MarcZX10. I've raised it on #8483 (comment) and will settle with its author and the maintainers which of the two stays; the other then closes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:11:56Z.
Thanks for raising the duplicate with #8483. I still do not see an agreement from that PR author or maintainers on which implementation will proceed, so the duplicate remains unresolved. Also, #7605 edits the same
pollloop and the PR body describes the changes as composing; please list the required merge order underDepends onand preserve that rebase sequence. Once the duplicate choice is settled, update or close the superseded PR, update the checklist, and rebase the surviving branch on currentmainbefore requesting another review. I have not rerun tests locally.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T02:19:02Z.
Thanks, @MarcZX10. Depends on now lists #7605, and the Overlap section says this PR goes after it and rebases on it. On #8483, the question of which one stays is with its author and the maintainers. Once it's settled, the other closes, and the surviving branch gets its checklist updated and is brought up to date with current
mainbefore another review.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:27:16Z.
Review: CHANGES_REQUESTED
The Windows
polltranslation is scoped to streamPOLLHUPwithoutPOLLERR, and its regression checks half-close, peer close/EOF, and the both-directions-shut state. The PR correctly records #7605 as a prerequisite and includesFixes: #8482; #8482 remains open. However, duplicate work #8483 is also still open and implements the same behavior. The PR itself says one should close, but there is still no author/maintainer decision. Please resolve that choice with #8483’s author and maintainers, update/close the superseded PR, and preserve the #7605 order. This branch and its tests are based ona6dcea9279, while current upstream main isab347d144d; rebase the surviving PR and rerunguest_poll, conventions and overlap checks on current main. Also preserve the #8344/#8483/#8670 debt edits and manually compare #5021’s Udp.cpp warning. Hosted product jobs are skipped; I did not run local tests.Pull request closed