fix(libSceNet): report the receive queue length in sceNetGetSockInfo #12683
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12683"
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 xXPBSXx on 2026-10-29T01:59:01Z.
What
Carries #9932 (ntamas94, head
641b92a91c; its three commits keep their authorship, the four merge commits of that branch are not carried), rebased onto currentmain. The maintainer asked on that PR to mergemain, keep its socket-option wording and combine thesceNetGetSockInfoentries indocs/dev/debt/libSceNet.md; the author has not answered since 23 October, and the hand-off was offered there on 27 October.sceNetGetSockInfoalways reported 0 inrecv_queue_length(offset 0x2c), so a title that polls the record and reads only when the queue is not empty never reads. The record now carries the host'sFIONREADcount for the socket; a socket where the host refusesFIONREADkeeps 0.guest_sce_netgains rows that queue bytes on a connected TCP pair, wait for the receiver's record to report them and check that a receive empties it.The only conflict was in
docs/dev/debt/libSceNet.md. After the rebase thesceNetGetSockInfoentry ofmainkeeps its wording except that "queue lengths" now reads "send queue length", and a new entry below it records the receive queue: the host count, the datagram-socket differences between hosts, and the author's PS4 Pro readings. Those readings are the author's report and were not measured here.The read goes through the host's
FIONREADdirectly, so on macOS it does not follow the datagram counting that #10628 gavesceNetIoctl; that difference is not measured here and is left to a follow-up.Tested
Windows 10 Pro (19045), WinLibs GCC 15.2.0 r7, Ninja Release,
BUILD_TESTING=ON, onmain3a2b919816with this branch on top (ninja exit code 0), 3 runs each:guest_sce_netpasses in all three runs, and again in three runs after the changed files were restored.mainwithlibSceNet/Export.cppreverted and the test kept:guest_sce_netaborts in all three runs (exit code0xc0000409). A one-off build that printed the failing line showed it stops at the new check that the receive queue length equals the seven bytes queued (GuestSceNet.cpp, three runs); that build carried a temporary change to the test'sRequireand is not part of this branch.python tools/check_conventions.py --base upstream/mainpasses,git diff --checkis clean, andgit merge-treeagainst currentmainis clean.Overlap
I took the changed files of each of the 1379 open pull requests from
git diff --name-onlyagainst its merge base withmain(3a2b919816; every ref was fetched): 20 of them, this one's source #9932 included, change at least one oflibSceNet/Export.cpp,GuestSceNet.cppanddocs/dev/debt/libSceNet.md.git merge-treeof this branch with each of the other 19, each on the merge base git finds, reports a conflict for 6 (#5836, #9948, #11134, #11272, #11872, #11969). Four of those already conflict withmainon their own, so this change adds no landing order for them. #9948 (by the same author, whose description says it depends on #9932) and #11272 (Queuse, "keep TCP option state") conflict only with this branch. #9948 follows this pull request and rebases onto it. For #11272, whichever lands second rebases and keeps both changes; which of the two lands first is open, and this pull request does not fix the order.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)Co-authored by the original author of #9932.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T02:03:25Z.
Review: COMMENTED
Ran the host side on macOS and Linux, which the body lists as not run. I used a plain C probe of the same calls
fill_sock_infonow makes (ioctl(FIONREAD)), plus theSO_NREADpath thatsceNetIoctluses on macOS. I did not buildguest_sce_neton either host.Stream sockets (what the new test checks): matches on both hosts.
FIONREADFIONREAD"queued"+ NUL)EINVAL→ record keeps 0So the new rows should pass on macOS and Linux as well, and the Linux listener case goes through the "host refuses
FIONREADkeeps 0" branch as the body describes. This matters because the PR'slinuxCI lane is skipped.Datagram sockets: one correction to the new debt line, and the follow-up the body left open is now measured.
macOS, one bound UDP socket, loopback sends,
FIONREADafter each step (SO_NREADin brackets):The debt line says "macOS adds 16 bytes for the first datagram and 32 for each later one". That only holds for the first datagram a socket ever receives. Once that socket's queue has drained, every datagram adds 32, including the first one queued afterwards (10 → 42, 0 → 32). Suggested wording: "macOS adds 16 bytes for the first datagram a socket receives and 32 for every other". Linux in the same sequence: 10, 10, 30, 0 and 0 → 0 for the empty-first case, which matches the line.
On macOS,
sceNetIoctl(FIONREAD)(the #10628SO_NREADpath) and this record now disagree on the same datagram socket: 10 vs 26, then 10 vs 88 in the first row above. On stream sockets they agree, since both useFIONREAD. The body leaves the macOS difference unmeasured, and the numbers above settle it. Neither host value is the PS4 Pro's payload+16 count, so I would not block on it. Two ways to close it: one sharedpending byteshelper so the two exports can't drift apart, or a sentence in the new debt line saying the record andsceNetIoctldisagree on macOS datagrams.No change requested to the code. The stream path is right on macOS and Linux here, and on Windows in your runs.
Pull request closed