fix(libkernel): report the accept queue length for a listening socket's read event #7140
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7140"
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-17T13:30:54Z.
What
A read event on a listening socket (
keventEVFILT_READandsceKernelAddReadEvent) took itsdatafromFIONREAD, which Linux refuses on a listening socket. So the event fired withdata0: "ready, zero connections". FreeBSD 11.4 attachesfilt_solistento a listening socket, which reportsso_qlen, the completed connections waiting foraccept.GuestSockets::Readynow checksSO_ACCEPTCONN. On Linux it reads a TCP listener's accept backlog fromTCP_INFO; for a listening socket,tcp_get_infoputs the number of children ready foraccept()intcpi_unacked. Where the host has no call for the count (Windows, macOS, a listener that is not TCP), it reports 1, the lower bound the readiness already implies. The debt entry says so.Two commits:
fix(libkernel): report the accept queue length for a listening socket's read event: theUdp.cppchange and the debt entry.test(libkernel): check the queued connection count on a listening socket: inguest_socket_events,datais 1 after the first connect and, on Linux, 2 once a second client is waiting, before both are accepted.Tested
Linux x86_64:
guest_socket_events,guest_kqueue,guest_pollandguest_selectpassed 5 of 5 runs. With the fix reverted,guest_socket_eventsfails at the new check.tools/check_conventions.py --base upstream/mainpasses; the progress report is unchanged. Not run on Windows or macOS, where the value is the fallback 1.Stacked on the socket write-space PR, since both change the data reported by
GuestSockets::Readyand the same debt entry. Until that one merges, its two commits also show here.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-17T13:46:29Z.
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.mdL127-128docs/dev/debt/libkernel.mdL127-128Some 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.mddocs/dev/debt/libkernel.mdcore/libs/tests/GuestSocketEvents.cppcore/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.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T14:05:48Z.
The checklist still has the literal
Depends on: #<socket write-space PR number>. The first two commits in this branch are the same socket write-space change and test carried by open #7076, so please name#7076there. That will also make the dependency clear to the intake/overlap checks.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T14:08:21Z.
Follow-up: the latest conventions run confirms the blocker is exactly the dependency placeholder (
Fill in the pull request template: fill Depends on with #N or none). The first two commits match the socket write-space implementation in #7076, so please replace the placeholder with#7076; that should clear this failure and accurately state the stack dependency.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T23:29:45Z.
The latest conventions check fails on the dependency placeholder:
Depends on: #<socket write-space PR number>. Could you replace it with the actual PR number, ornoneif the write-space commits included on this branch make it self-contained? The check is currently red for this field.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T11:51:58Z.
Thanks for the rebase onto #7076. One thing left before merge: the PR body still has the placeholder
Depends on: #<socket write-space PR number>, and the conventions check is red on exactly that line. Could you change it toDepends on: #7076(now merged), ornone? Either one passes.Imported from boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-18T12:02:24Z.
Rebased onto current main: the two #7076 commits are gone now that it is merged, and "Depends on" is set to none. I also dropped my own SO_ACCEPTCONN helper in favour of the
Listening(const Socket&)that main gained in the meantime, so the change is now only the accept-queue count. guest_socket_events, guest_kqueue, guest_poll and guest_select pass 5/5 on Linux.