Skip to content

fix(libSceNet): report the receive queue length in sceNetGetSockInfo - #12683

Closed
xXPBSXx wants to merge 4 commits into
boykopovar:mainfrom
xXPBSXx:carry/9932-sockinfo-recvq
Closed

xXPBSXx wants to merge 4 commits into
boykopovar:mainfrom
xXPBSXx:carry/9932-sockinfo-recvq

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

Carries #9932 (ntamas94, head 641b92a91c; its three commits keep their authorship, the four merge commits of that branch are not carried), rebased onto current main. The maintainer asked on that PR to merge main, keep its socket-option wording and combine the sceNetGetSockInfo entries in docs/dev/debt/libSceNet.md; the author has not answered since 23 October, and the hand-off was offered there on 27 October.

sceNetGetSockInfo always reported 0 in recv_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's FIONREAD count for the socket; a socket where the host refuses FIONREAD keeps 0. guest_sce_net gains 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 the sceNetGetSockInfo entry of main keeps 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 FIONREAD directly, so on macOS it does not follow the datagram counting that #10628 gave sceNetIoctl; 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, on main 3a2b919816 with this branch on top (ninja exit code 0), 3 runs each:

  • This branch: guest_sce_net passes in all three runs, and again in three runs after the changed files were restored.
  • Same main with libSceNet/Export.cpp reverted and the test kept: guest_sce_net aborts in all three runs (exit code 0xc0000409). 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's Require and is not part of this branch.
  • python tools/check_conventions.py --base upstream/main passes, git diff --check is clean, and git merge-tree against current main is clean.
  • Not run here: Linux and macOS, the full suite, and any title. The PS4 Pro values come from fix(libSceNet): report the receive queue length in sceNetGetSockInfo #9932's description and are not re-measured.

Overlap

I took the changed files of each of the 1379 open pull requests from git diff --name-only against its merge base with main (3a2b919816; every ref was fetched): 20 of them, this one's source #9932 included, change at least one of libSceNet/Export.cpp, GuestSceNet.cpp and docs/dev/debt/libSceNet.md. git merge-tree of 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 with main on 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

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: fix(libSceNet): describe sockets made with socket() in sceNetGetSockInfo #9948
  • GPUs tested: n/a
  • AI-assisted: yes

Co-authored by the original author of #9932.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

ntamas94 and others added 3 commits October 29, 2026 00:36
sceNetGetSockInfo always reported 0 in recv_queue_length, so a title that
reads a socket only when its record shows queued data never reads. The
record now carries the host's FIONREAD count; a socket the host refuses
FIONREAD for keeps 0, the value a PS4 Pro on firmware 10.71 reports for
an empty queue. The datagram difference between hosts and the other
measured values of the record are recorded as technical debt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rooklz rooklz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_info now makes (ioctl(FIONREAD)), plus the SO_NREAD path that sceNetIoctl uses on macOS. I did not build guest_sce_net on either host.

Stream sockets (what the new test checks): matches on both hosts.

socket macOS 26.2 arm64 FIONREAD Ubuntu 24.04 x86_64 glibc 2.39 FIONREAD
accepted, empty 0 0
accepted, 7 bytes queued ("queued" + NUL) 7 7
accepted, 7 bytes + peer FIN 7 7
listener 0 fails EINVAL → record keeps 0

So the new rows should pass on macOS and Linux as well, and the Linux listener case goes through the "host refuses FIONREAD keeps 0" branch as the body describes. This matters because the PR's linux CI 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, FIONREAD after each step (SO_NREAD in brackets):

fresh socket : send 10 -> 26 [10]   send 30 -> 88 [10]   recv -> 62 [30]   recv -> 0
same socket  : send 10 -> 42        send 30 -> 104       recv -> 62        recv -> 0
             : send 0  -> 32        send 5  -> 69        recv -> 37        recv -> 0
             : send 1 x4 -> 33 66 99 132                 recv x4 -> 99 66 33 0

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 #10628 SO_NREAD path) 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 use FIONREAD. 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 shared pending bytes helper so the two exports can't drift apart, or a sentence in the new debt line saying the record and sceNetIoctl disagree 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.

@adriadam10 adriadam10 self-assigned this Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Some 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.

Pull request Shared files not compared
PR 5836 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 7490 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
PR 9948 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 10629 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 11559 core/libs/prx/libSceNet/Export.cpp
PR 11571 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 12104 docs/dev/debt/libSceNet.md
PR 12682 core/libs/prx/libSceNet/Export.cpp
PR 12688 core/libs/prx/libSceNet/Export.cpp
PR 12700 core/libs/prx/libSceNet/Export.cpp
PR 12918 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 12965 core/libs/prx/libSceNet/Export.cpp
PR 13098 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 13486 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 14009 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 14183 core/libs/prx/libSceNet/Export.cpp
PR 14212 docs/dev/debt/libSceNet.md
PR 14213 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 14902 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 15076 docs/dev/debt/libSceNet.md
PR 15701 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md

@JJenkx

JJenkx commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Windows run of this head (3d93e93696), merged onto main 3a2b919816 (clean merge, local only). Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release, BUILD_TESTING=ON, no Vulkan driver visible.

  • This PR: guest_sce_net and guest_sce_net_keepalive pass 3 of 3 (ctest --repeat until-fail:3).
  • Negative control: with core/libs/prx/libSceNet/Export.cpp put back to main's version and everything else from this PR, 1 of the 2 fails.

AI-assisted: yes (Claude Code).

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@xXPBSXx reviewed at b6d748c: a faithful carry of #9932. ntamas94's three commits keep their authorship and the net diff matches #9932 (bar the <sys/ioctl.h> include that main already has). The maintainer's asks on #9932 are met: main merged, the socket-option wording kept, and the sceNetGetSockInfo entries combined in the debt file with the datagram host differences and the PS4 Pro readings marked as the author's report. The new guest_sce_net rows poll the record with a bound and expect exactly the sent length. No requests. Landing note: #9948 conflicts with this in Export.cpp, so it lands after this one; #9932 can be closed as superseded once this merges.

@adriadam10 we'll merge this once exact-head CI is green, unless you'd rather merge it yourself.

@blawesom

Copy link
Copy Markdown
Contributor

Cross-posting a duplicate-PR notice (produced by tools/pr_overlap.py's dedup pass over the current open backlog).

Possible duplicate of #9932 (ntamas94, opened 2026-10-22) — "fix(libSceNet): report the receive queue length in sceNetGetSockInfo".

Both PRs implement the same sceNetGetSockInfo receive-queue-length behavior and both touch the same three files (core/libs/prx/libSceNet/Export.cpp, core/libs/tests/GuestSceNet.cpp, docs/dev/debt/libSceNet.md). This PR also adds an attach response + sceNetSendAttachmentData int return fix that #9932 does not; #9932 is older and currently does not merge cleanly into main.

Not making a judgement call on which should land — flagging so the two of you and a maintainer can decide before both reviewers' time is spent twice. Happy to re-verify whichever is chosen.

@xXPBSXx

xXPBSXx commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing: this carried #9932, which was merged on 2026-11-02 at 07:59 UTC, so this pull request is no longer needed.

AI-assisted (Claude Code).

@xXPBSXx xXPBSXx closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs needs rebase Conflicts with main, rebase needed prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants