feat(libkernel): accept MSG_WAITALL in recv, recvfrom and recvmsg on a stream socket #8474

Merged
xXPBSXx merged 1 commit from upstream-pr/8474 into main 2026-10-21 18:00:46 +00:00
xXPBSXx commented 2026-10-20 13:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T13:17:01Z.


What

recv, recvfrom and recvmsg failed every flag but MSG_PEEK and MSG_DONTWAIT with EOPNOTSUPP. FreeBSD 11.4 accepts MSG_WAITALL (0x40) and, on a stream socket, keeps the receive waiting until the buffer is full, the peer closes or an error occurs (soreceive_generic). A stream socket now passes the flag to the host receive (MSG_WAITALL on Winsock and Linux); a datagram socket ignores it, as a record is delivered whole. The Technical debt entry says what is not measured: nonblocking sockets and MSG_WAITALL | MSG_PEEK follow the host, and SO_RCVTIMEO bounds only the wait for the first data.
Fixes #8473
Overlap: #7090 (SCM_RIGHTS, open) also changes recvmsg; git merge-tree of the two heads has two conflicts in Udp.cpp, so whichever lands second rebases. git merge-tree against #8392, #8448, #8463, #7511, #7502, #7485, #7850 and #7490 is clean. pr_overlap was not run.

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 44e3389c88 + this commit:

  • guest_tcp: the new case aborts without the change to Udp.cpp (recv with 0x40 answers EOPNOTSUPP) and passes with it. It checks a 4+4 byte request split by 150 ms, a short result when the peer closes after 2 bytes (recvfrom), and a datagram socket that ignores the flag.
  • guest_sce_net, guest_socket_error, guest_socket_options, guest_socket_timeouts, guest_udp, guest_poll, guest_socket_pair and guest_recvmsg_memory pass.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux/macOS, a console, a title run, recvmsg with MSG_WAITALL (same flag path as recvfrom, no dedicated case), a nonblocking socket.

Checklist

  • Based on current main; no other open PR implements the same functions (#7090 changes recvmsg for SCM_RIGHTS)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: #8473
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4936317537 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8474). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T13:17:01Z. --- ### What `recv`, `recvfrom` and `recvmsg` failed every flag but `MSG_PEEK` and `MSG_DONTWAIT` with `EOPNOTSUPP`. FreeBSD 11.4 accepts `MSG_WAITALL` (0x40) and, on a stream socket, keeps the receive waiting until the buffer is full, the peer closes or an error occurs ([`soreceive_generic`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/uipc_socket.c#L1855-L1860)). A stream socket now passes the flag to the host receive (`MSG_WAITALL` on Winsock and Linux); a datagram socket ignores it, as a record is delivered whole. The Technical debt entry says what is not measured: nonblocking sockets and `MSG_WAITALL | MSG_PEEK` follow the host, and `SO_RCVTIMEO` bounds only the wait for the first data. Fixes #8473 Overlap: #7090 (SCM_RIGHTS, open) also changes `recvmsg`; `git merge-tree` of the two heads has two conflicts in `Udp.cpp`, so whichever lands second rebases. `git merge-tree` against #8392, #8448, #8463, #7511, #7502, #7485, #7850 and #7490 is clean. `pr_overlap` was not run. ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 44e3389c88 + this commit: - `guest_tcp`: the new case aborts without the change to `Udp.cpp` (`recv` with `0x40` answers `EOPNOTSUPP`) and passes with it. It checks a 4+4 byte request split by 150 ms, a short result when the peer closes after 2 bytes (`recvfrom`), and a datagram socket that ignores the flag. - `guest_sce_net`, `guest_socket_error`, `guest_socket_options`, `guest_socket_timeouts`, `guest_udp`, `guest_poll`, `guest_socket_pair` and `guest_recvmsg_memory` pass. - `python tools/check_conventions.py --base upstream/main`: passes. - Not tested: Linux/macOS, a console, a title run, `recvmsg` with `MSG_WAITALL` (same flag path as `recvfrom`, no dedicated case), a nonblocking socket. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#7090 changes `recvmsg` for SCM_RIGHTS) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: #8473 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-20 13:33:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T13:33:35Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7090 core/libs/prx/libkernel/Socket/src/Udp.cpp L1520-1521
docs/dev/debt/libkernel.md L190

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 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestTcp.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6879 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7447 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7653 docs/dev/debt/libkernel.md
PR 8520 docs/dev/debt/libkernel.md
PR 8547 docs/dev/debt/libkernel.md
PR 8726 docs/dev/debt/libkernel.md
PR 9099 docs/dev/debt/libkernel.md
PR 9137 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6292090715 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8474#issuecomment-6292090715). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T13:33:35Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7090](https://www.github.com/boykopovar/AnyPS5/pull/7090) | `core/libs/prx/libkernel/Socket/src/Udp.cpp` [L1520-1521](https://github.com/boykopovar/AnyPS5/blob/95d17687aed6bad81082d9bbef01cb1d9c0a384c/core/libs/prx/libkernel/Socket/src/Udp.cpp#L1520-L1521)<br>`docs/dev/debt/libkernel.md` [L190](https://github.com/boykopovar/AnyPS5/blob/95d17687aed6bad81082d9bbef01cb1d9c0a384c/docs/dev/debt/libkernel.md#L190) | | | 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 4630](https://www.github.com/boykopovar/AnyPS5/pull/4630) | `docs/dev/debt/libkernel.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestTcp.cpp` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `docs/dev/debt/libkernel.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libkernel.md` | | [PR 6740](https://www.github.com/boykopovar/AnyPS5/pull/6740) | `docs/dev/debt/libkernel.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `docs/dev/debt/libkernel.md` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `docs/dev/debt/libkernel.md` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7149](https://www.github.com/boykopovar/AnyPS5/pull/7149) | `docs/dev/debt/libkernel.md` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `docs/dev/debt/libkernel.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/Socket/src/Udp.cpp` | | [PR 7447](https://www.github.com/boykopovar/AnyPS5/pull/7447) | `docs/dev/debt/libkernel.md` | | [PR 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `docs/dev/debt/libkernel.md` | | [PR 7653](https://www.github.com/boykopovar/AnyPS5/pull/7653) | `docs/dev/debt/libkernel.md` | | [PR 8520](https://www.github.com/boykopovar/AnyPS5/pull/8520) | `docs/dev/debt/libkernel.md` | | [PR 8547](https://www.github.com/boykopovar/AnyPS5/pull/8547) | `docs/dev/debt/libkernel.md` | | [PR 8726](https://www.github.com/boykopovar/AnyPS5/pull/8726) | `docs/dev/debt/libkernel.md` | | [PR 9099](https://www.github.com/boykopovar/AnyPS5/pull/9099) | `docs/dev/debt/libkernel.md` | | [PR 9137](https://www.github.com/boykopovar/AnyPS5/pull/9137) | `docs/dev/debt/libkernel.md` |
adriadam10 commented 2026-10-21 18:01:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T18:01:09Z.


Checked the flag path against FreeBSD 11.4 soreceive_generic (stream passes MSG_WAITALL to the host, datagram ignores it), all three call sites on current main, the new guest_tcp case (fails with EOPNOTSUPP without the change) and the debt entry; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322935817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8474#issuecomment-6322935817). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T18:01:09Z. --- Checked the flag path against FreeBSD 11.4 `soreceive_generic` (stream passes `MSG_WAITALL` to the host, datagram ignores it), all three call sites on current `main`, the new `guest_tcp` case (fails with `EOPNOTSUPP` without the change) and the debt entry; merged.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8474
No description provided.