fix(libkernel): report free send space for socket write events on Linux #7076
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7076"
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 AlexOfTheForest on 2026-10-17T10:29:56Z.
What
A socket's
EVFILT_WRITE(fromkeventand fromsceKernelAddWriteEvent) reported the wholeSO_SNDBUFindata, however much was already queued. FreeBSD 11.4'sfilt_sowritereportssbspace(&so->so_snd), the space still free. On Linux,GuestSockets::Readynow subtracts the queued bytes fromSIOCOUTQ. Those include the host's per-packet overhead, so the value drops by somewhat more than the bytes sent. Windows has no query for the queued bytes and macOS is not wired up, so both still reportSO_SNDBUF. The existing libkernel debt entry, which listed this gap, is updated.Two commits:
fix(libkernel): report free send space for socket write events on Linux: theUdp.cppchange and the debt entry.test(libkernel): check socket write event space shrinks and recovers: inguest_kqueue, on a Unix stream socketpair,datadrops by at least the 1000 bytes sent while the peer has not read them, and returns to the idle value once the peer drains them. Off Linux the test only checks that the value stays positive and never grows.Tested
Linux x86_64:
guest_kqueue,guest_socket_events,guest_pollandguest_selectall passed 5 of 5 runs. With the fix reverted,guest_kqueuefails at the new check.tools/check_conventions.py --base upstream/mainpasses; the progress report is unchanged. Not run on Windows or macOS, where the behaviour is unchanged. Merges cleanly withfeat/kevent-pipe-write; the two PRs don't depend on each other.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-17T10:51:37Z.
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)docs/dev/debt/libkernel.mdL128-129Some 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.
core/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdcore/libs/tests/GuestKqueue.cppcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdcore/libs/tests/GuestKqueue.cppdocs/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.cpp