Repository navigation
feat(libkernel): implement read and write events for guest sockets - #1091
Conversation
|
Conflicts with main in |
9dc3924 to
7f5f456
Compare
|
Rebased on main (e705d43). In |
Progress report (e28fbc2 → 0abe0b8)📉 System libraries: 85.62% (-0.04%, +2 implemented, +2 declared functions) ✅ 2 implemented
🆕 2 declared as stubs
|
|
Conflicts with main again, in |
|
Rebased onto current main (conflicts with the socketpair and poll work in Checked on Linux after the rebase: full build and ctest green (523/523), |
7f5f456 to
96eb4ad
Compare
|
Conflicts with main again in |
sceKernelAddReadEvent/DeleteReadEvent and sceKernelAddWriteEvent/ DeleteWriteEvent register EVFILT_READ and EVFILT_WRITE events on guest sockets. The equeue polls the host socket for readiness on each wait and reports the readable byte count or the send buffer size in data, with EV_EOF on hang-up or error.
A wait on an equeue that holds socket events now blocks in poll/WSAPoll on those sockets plus a per-thread loopback wake socket, instead of rechecking every millisecond. Adding, triggering or deleting an event and closing the equeue wake the blocked waiters. Closing a socket removes its read and write events, as on FreeBSD. A read event also reports EV_EOF once the peer has shut down its sending side.
|
Rebased onto current main (conflicts in |
96eb4ad to
0abe0b8
Compare
|
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.
|
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 feat(libkernel): support SO_LINGER and IPV6_V6ONLY in setsockopt #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)