feat(libkernel): select on pipes on Windows #5013
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5013"
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 p3n1cillin on 2026-10-13T08:13:11Z.
What
On Windows,
selectthrew for any descriptor that is neither a guest socket nor a libSceNet socket. RetroArch (PPSA99169) in RetroArch mode stops there:gdb shows the throw on the
MHD-workerthread, GNU libmicrohttpd's server worker behind RetroArch's web UI. The descriptor is the read end of a pipe from the guest'spipe()(gdb onpipe_nid_postfixreturned 4 and 5): libmicrohttpd's inter-thread wake-up channel, selected next to its listening socket. #3644 already taughtpollto handle such a pipe;selecthad no Windows counterpart for its host group.select's host group now has a Windows poller too. It uses the samePipeReadinesstest aspoll(Udp.cpp, exposed asGuestSockets::PipeReady): readable with data or when the write end is closed, writable with at leastPIPE_BUF(512) bytes of quota. It checks the pipes every millisecond until the slice ends, and reportsEBADFfor a closed descriptor as Linux'sHostPolldoes. A descriptor that is neither a socket nor a pipe still throws, now saying so. Linux is unchanged. Theselectentries indocs/dev/debt/libkernel.mdare updated.Tested
guest_select, which was registered only off Windows, now runs on Windows and passes. It covers an idle pipe timing out, a readable read end, a writable write end, both at once, a pipe next to a guest socket with both ready, andEBADFafter closing. Without the change it fails on Windows (it throws on the first pipe). All 124 libkernel tests pass on Windows 11 (MinGW GCC 15.2.0); the Linux path is unchanged and was not rebuilt locally.retroarch.logshows the Vulkan swapchain,[Autoconf] PS5 Controller configured in port 1, and the playlists loaded, with about 11 submissions per second.python tools/check_conventions.py --base origin/main,tools/check_test_registration.pyandtools/pr_overlap.pypass.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T09:07:47Z.
Follow-up Linux validation of this change on current
main4bb2c7f3947440d513b1dbd12143ec55b250495a: cleanly cherry-picked PR head76a168fccca9ceae399be9f4077db19fccce420ainto an isolated local branch, alongside the independent libctznamechange from #5009. Exact integration head:2e3b9eb35c775e1d429f6c42144a701a632859ae.Ubuntu 26.04.1 / WSL2, GCC 15.2.0, Ninja Release, bundled dependencies,
BUILD_TESTING=ON. Built the real libc and libkernel libraries and all their Linux-registered test targets. All 187 scoped tests passed (66 libc, 121 libkernel), no skips or failures, 3.73 s.guest_selectpassed in 0.30 s, including idle/readable/writable pipes, simultaneous pipe/socket readiness and closed-descriptor EBADF. Conventions and whitespace checks passed on the integration branch.This was a scoped library build and native Linux test run, not a full Linux application build or a Linux RetroArch run. No further game run was performed. AI-assisted validation with Codex; Claude's original implementation remains unchanged.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:19:34Z.
Review: COMMENTED
Reusing
PipeReadinessfrompollkeeps the two consistent. One timing detail: the new WindowsHostPollloop waits withstd::this_thread::sleep_for(std::chrono::milliseconds(1)). On Windows that sleep follows the coarse system tick and usually takes about 15.6 ms, as measured in #1471, which is why #4980 (poll) and #4754 (selecttimeouts) move these waits toPreciseSleepUs.For libmicrohttpd's wake-up pipe, that means each wake-up of the
MHD-workerthread can be delayed by up to ~15 ms. Aselectwith a short timeout also overshoots it by the same amount.PreciseSleepUs(1000)(high-resolution waitable timer, no spinning) gives the 1 ms slice the description intends at the same CPU cost.Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-14T07:27:33Z.
Rebased onto
main78f1aea70(headf288daf6f).mainnow has precise select timeouts and the newguest_select_waittest. I kept both: the two includes inSocket.cpp, and in CMakeguest_select_waitstays as it is whileguest_selectis registered on Windows too, as before.main'sHostPollstill only polls host descriptors on Unix, so the Windows pipe path is still needed. On Windows (MinGW GCC 15, Release),guest_selectandguest_select_waitpass, the libkernel suite passes (oneguest_memoryfailure under-j8passes 3/3 alone and is unrelated), and the conventions check passes.