feat(libkernel): implement read and write events for guest sockets #1091
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1091"
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 kjhq on 2026-10-07T10:38:22Z.
What
Implements
sceKernelAddReadEvent,sceKernelDeleteReadEvent,sceKernelAddWriteEventandsceKernelDeleteWriteEventfor guest sockets (EVFILT_READ-1,EVFILT_WRITE-2).KernelFiltergets an optionalpollFunc.GetTriggeredEventsandWaitForEventscall it for every event that has one and settriggeredfrom the result.GuestSockets::Readychecks the host socket (poll/WSAPoll) with a zero timeout. A read event reports the readable byte count (FIONREAD) indataand a write event the send buffer size (SO_SNDBUF).EV_EOFis set onPOLLHUP/POLLERR, and for a read event also once the peer has shut down its sending side (POLLRDHUPon Linux). Events are level-triggered, as in kqueue withoutEV_CLEAR.ppoll/WSAPollon the sockets of the queue's descriptor events plus a per-thread loopback UDP wake socket.ppoll/WSAPolltimeout.WSAPollcounts in milliseconds, so on Windows the last sub-millisecond before a deadline is waited on the queue's condition variable.closedoes on FreeBSD.EBADF.datais the send buffer size, not the free space in it.WaitForEventschanges next to the lines #1081 touches (the blocking wait with no timeout); the two do not overlap in behaviour, but whichever merges second needs a small rebase.New test
guest_socket_events(TCP over loopback) checks:data > 0data == 0andEV_EOFafter the peer closesENOENT)ENOENT, a closed socket isEBADF, and a non-socket descriptor and a large low watermark throwWith the wake on
AddEventremoved, the test hangs.Title
PPSA17221 (Minecraft) needs #716 to load the modules in its app root, so every run below is current
main+ #716 + the PRs of this set (#1088, #1090–#1096), plus local changes outside it: dialog, NpAuth and TextToSpeech2 stubs that open PRs cover (#560, #925, #301) and a GPU end-of-pipe change that is not submitted. With all of them the title loads a world. The line below is from a run with only this PR left out, Windows 11, WinLibs GCC, normal user session.Without it startup stops at load:
JxJ4tfgKlXAissceKernelDeleteReadEvent; the eboot also importssceKernelAddReadEvent(VHCS3rCd0PM),sceKernelAddWriteEvent(R-tyYMpYaxY) andsceKernelDeleteWriteEvent(cBGTk8S92XM).Tested
Debian 13 (WSL2), GCC 14.2.0, Release: full
ctest, 0 of 391 failed (151 AGC driver tests report Skipped on this machine), includingguest_socket_eventsandguest_equeue_events.Windows 11, WinLibs GCC:
guest_socket_eventsandguest_tcppass.guest_udppasses once theSO_LINGERchecks are removed. Those checks come from the closed #1090, which is still in the local integration tree, and Windows rejectsSO_LINGERon UDP sockets.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:25:40Z.
Conflicts with main in
Equeue.cppandEqueue.hpp(themicros == 0branch changed in #807); please rebase.Imported from boykopovar/AnyPS5. Originally posted by kjhq on 2026-10-08T08:25:56Z.
Rebased on main (
e705d430). InWaitForEvents, an infinite wait now takes the timer deadline from #807 and, while socket events are registered, waits inWaitForDescriptorsuntil that deadline. Linux:guest_socket_events,guest_equeue_eventsandguest_udppass. The full ctest has one failure,tls_function_coverage(alu-exec-xor-3exits with SIGSEGV), which fails the same way on main.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T09:03:33Z.
Progress report (
e28fbc2→0abe0b8)📉 System libraries: 85.62% (-0.04%, +2 implemented, +2 declared functions)
✅ 2 implemented
sceKernelDeleteReadEventsceKernelDeleteWriteEvent🆕 2 declared as stubs
sceKernelAddReadEventsceKernelAddWriteEventImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:21:52Z.
Conflicts with main again, in
Socket/src/Udp.cppanddocs/dev/TechnicalDebt.md; please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:29:38Z.
Rebased onto current main (conflicts with the socketpair and poll work in
Udp.cpp,libkernel/CMakeLists.txtandTechnicalDebt.md; adjacency only, no logic changes). The two commits are kept, no merge commits.Checked on Linux after the rebase: full build and ctest green (523/523),
guest_socket_eventsdoes not link without the change. Windows paths (WSAPoll, waker socket) are covered only by the author's Windows 11 run; merging on green CI.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:16:27Z.
Conflicts with main again in
Socket/include/SocketRuntime.hpp(#1738); please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:56:51Z.
Rebased onto current main (conflicts in
libkernel/CMakeLists.txt,SocketRuntime.hppandTechnicalDebt.md: kept main'sguest_dup,Duplicate/Family/Read/Writeandshm_openline next to this PR'sguest_socket_events,Readyand TechnicalDebt line). No logic changes, both commits kept, no merge commits. Rebuilt on Linux: scoped ctest 92/92 passes, includingguest_socket_events,guest_socket_pair,guest_socket_read_write,guest_equeue_events,guest_udpandguest_tcp. Windows paths (WSAPoll, waker socket) are covered only by the author's Windows 11 run; merging on green CI.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T23:58:50Z.
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)core/libs/prx/libkernel/Socket/include/SocketRuntime.hppL12