fix(libkernel): report a regular file ready in poll #6962
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6962"
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 DavidSamir on 2026-10-16T21:22:44Z.
What
pollthrew for an open descriptor that is neither a guest socket, a libSceNet socket nor a pipe, so a title that polls a file it has open stopped at the first call. VLC for PS5 (PPSA85300) polls a media file from its folder forPOLLINwith a 20 ms timeout. On Windowsmainends 2 to 5 s in, before any button is pressed:Now a regular file (
FILE_TYPE_DISKon Windows,S_ISREGon Linux) reports thePOLLIN,POLLRDNORMandPOLLOUTbits it asked for as ready at once, which is what FreeBSD'svop_nopollreturns for a vnode. An event of onlyPOLLPRIorPOLLRDBANDis never ready and waits out the timeout like any other poll. Devices, stdio and directories still throw, and the poll entry indocs/dev/debt/libkernel.mdsays so.Related, not overlapping: #5999 does the same for
selecton Windows (Socket.cpp), #6070 and #5973 change pipes in this function.Three commits: the change, its test, and the debt entry. There is no fourth step.
Tested
Windows 11 Pro build 26300, Intel i7-11700F, NVIDIA GeForce RTX 3070, WinLibs GCC 15.2, Release, branch merged on
mainc842491865(it is based on it).--windows-fixed-base 0x400000(#4013) and--windows, with a 10 s, 991,017-byte clip of Big Buck Bunny (a Creative Commons film, from test-videos.co.uk) in the app's media folder,app0/media/:main: 7 of 7 runs stop after 2 to 5 s withpoll: descriptor 8 is neither a socket nor a pipe(descriptor 8 or 9). A probe on a scratch build showed descriptor 8 is...\app0\media\bbb360.mp4, file typeFILE_TYPE_DISK, eventsPOLLIN, timeout 20 ms.player: open /app0/media/bbb360.mp4 at 0 ms,player: VLC offers I420 640x386,player: pictures 640x386 8-bit, then the pause and play of the scripted button presses.TestRegularFileinguest_poll: one file for each ready bit, all three together,POLLPRI | POLLRDBANDonly (not ready, waits the 50 ms), a set with a socket, the file and an invalid descriptor (one ready, no wait), and the file afterclose(POLLNVAL). Windows: passes 5 of 5 with the change. Againstmain'sUdp.cppit aborts (0xC0000409).mainc842491865:guest_pollandguest_selectpass 3 of 3. WithUdp.cppas onmainand the new test,guest_pollaborts withpoll: descriptor 6 is neither a socket nor a pipe; restored, both pass.guest_poll,guest_select,guest_select_wait,guest_kqueue,guest_equeue_events, theguest_socket_*family,guest_sce_net,guest_net_ctl,guest_http*,guest_ssl*,guest_sendfile).tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch: one conflict, #5973 indocs/dev/debt/libkernel.md(it adds the line next to the poll entry; whichever merges second takes a trivial rebase). It could not compare #5021, #6044, #6222 and #6828 because they conflict withmainthemselves; read by hand, #6222 and #6828 edit other functions ofUdp.cpp(WaitAny,Ready,GuestSockets::Poll) and #6044 reorganises the tests.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-16T21:33:57Z.
Some 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.
docs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/tests/GuestPoll.cppdocs/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.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/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.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.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.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/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.cppdocs/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.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-17T00:35:10Z.
Native Linux run of this head (the description's Linux run was inside WSL2).
Setup: head
5ddebca1b(merge-base withmainc84249186),BUILD_TESTING=ON, Ninja, CachyOS (kernel 7.2.9), i9-11900K, GCC 16.2.1. Tests ran underenv -iwith onlyHOMEandPATHset. Each arm ranctest -R '^guest_(poll|select)$'3 times.Udp.cppas onc84249186and the PR's test kept,guest_pollfails 3 of 3 withpoll: descriptor 9 is neither a socket nor a pipe.guest_selectpasses.mainate751dd205: clean merge, 2 of 2 pass in each of the 3 runs.tools/check_conventions.pypasses.mainhas since moved tof3263dfbf; it does not touch this PR's files and the PR still merges cleanly.GuestPoll.cpplocally, not part of the PR, one run): a regular file opened read-only and polled forPOLLOUTreturns 1 withrevents0x4. By reading, that matches FreeBSD:vn_pollandvop_stdpolldo not check the open mode. A directory descriptor still throwsneither a socket nor a pipe, as the updated debt entry says.Optional, on the debt entry's citation. In FreeBSD 11.4,
vop_nopollis the default (vfs_default.c), while UFS sets.vop_poll = vop_stdpoll. By reading, for the bits this PR accepts, both returnevents & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)(vop_stdpoll,poll_no_poll). That is the same set asGuestPollReadable | GuestPollWritable(0x45, sincePOLLWRNORMisPOLLOUT).POLLPRIandPOLLRDBANDgive 0 because they are inPOLLSTANDARD. The behaviour does not change either way. The console's filesystem is not known to be UFS, so namingvop_nopollis also defensible.Not checked: Windows (
IsDiskFilethroughGetFileType), macOS, PS5 hardware, and VLC itself.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by karimibrahim07 on 2026-10-17T03:52:29Z.
Review: COMMENTED
Windows check of head
5ddebca1bmerged ontomaine3a8e4430(clean merge). Windows 11 Pro (26300), Ryzen 5 3600, WinLibs GCC 15.2.0 r7, Ninja Release.guest_pollwith the newTestRegularFile, plusguest_select*,guest_kqueue,guest_socket*,guest_tcpandguest_udp: 27 of 27 pass,--repeat until-fail:3.main'sUdp.cppand the new test kept,guest_pollaborts withpoll: descriptor 4 is neither a socket nor a pipe(0xc0000409), the VLC message.Code:
IsDiskFilecan't catch guest sockets. On Windows a socket number holds aNULhandle (FILE_TYPE_CHAR), and on Linux it is a duplicate of the host socket (S_ISSOCK). So a socket can't be reported as always ready. Returning only thePOLLIN | POLLRDNORM | POLLOUTbits that were asked for matches FreeBSD'svop_nopoll(events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM);POLLWRNORMisPOLLOUTthere). The test covers the cases that matter: no wait when the file is ready, a full wait when onlyPOLLPRI/POLLRDBANDis asked, a mixed set, andPOLLNVALafterclose.Overlap: #5973 conflicts with this PR only in
docs/dev/debt/libkernel.md. It adds akevent on a pipeline right after thepollentry that this PR rewrites. The resolution is to keep both lines: this PR'spolltext, then #5973's new line.Not checked: VLC itself (I don't have it here). The behaviour it needs is what
TestRegularFileexercises.AI-assisted: yes. I ran the build, the tests and the negative control above.
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-17T08:35:12Z.
Rebase handoff — rebased onto current
main(authorship unchanged). One conflict indocs/dev/debt/libkernel.md: the poll debt entry now carries your regular-file semantics, withmain's newer kevent-pipe entry kept after it.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesmainregression (agc_driver_tessellationsegfault, #4727), not this PRTo pick it up:
Head is
7fe77f717.Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-18T06:05:45Z.
Closing this as superseded by #7139 (merged 2026-10-18, AlexOfTheForest). On
main66e71b63d1,poll_nid_postfixanswers any vnode throughFile::IsVnodewithPOLLIN,POLLRDNORMandPOLLOUT, and never withPOLLPRI,POLLRDBANDorPOLLWRBAND. That is this PR's rule, and it also covers directories,/dev/randomand descriptors 0 to 2.PollsFilesAndDirectoriesinGuestPoll.cppchecks the same cases as this PR'sTestRegularFile: a file is ready at once, a band-only request waits out the timeout, and a socket and a file can be mixed in one call. Mergingmainhere now conflicts in both the test and the debt entry, and resolving it would only drop this PR's code.Thanks to @Dextroid17 and @karimibrahim07 for the Linux and Windows runs, and to @blawesom for the rebase.
AI-assisted: yes
Pull request closed