fix(libkernel): honour MSG_DONTWAIT in the socket send and receive calls on Windows #8186

Merged
xXPBSXx merged 1 commit from upstream-pr/8186 into main 2026-10-20 03:22:36 +00:00
xXPBSXx commented 2026-10-20 01:52:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T01:52:06Z.


What

Winsock has no per-call non-blocking flag. WaitForTransfer (Udp.cpp), which every send/receive call already runs, now answers a MSG_DONTWAIT call on Windows with a zero-timeout WSAPoll for POLLRDNORM/POLLWRNORM: EAGAIN (35) when the socket is not ready, otherwise the transfer goes on. GuestSendFlags/GuestReceiveFlags accept the flag on every host. The debt entry for MSG_DONTWAIT states the two remaining differences: the poll and the transfer are two host calls (a second thread can take the data in between), and a send larger than the socket buffer can still block where FreeBSD returns a partial count.
Fixes #8185
Overlap: git merge-tree against the open socket PR #7090 (SCM_RIGHTS on Unix sockets) conflicts in Udp.cpp; whichever lands second rebases. pr_overlap was not run.

Tested

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

  • guest_udp and guest_socket_timeouts: Exit code 0xc0000409 without the change to Udp.cpp, pass with it.
  • guest_socket_options, _read_write, _event, _descriptors, _connect_listening, _error, _stream_options, _pair, _port_zero, _descriptor_flags, _host_write and guest_sce_net pass (27 of 27).
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux/macOS (unchanged paths), a console, a title run. libSceNet is not changed and still answers EOPNOTSUPP on Windows.

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; 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
  • Unblocks: none
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4929863780 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8186). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T01:52:06Z. --- ### What Winsock has no per-call non-blocking flag. `WaitForTransfer` (Udp.cpp), which every send/receive call already runs, now answers a `MSG_DONTWAIT` call on Windows with a zero-timeout `WSAPoll` for `POLLRDNORM`/`POLLWRNORM`: `EAGAIN` (35) when the socket is not ready, otherwise the transfer goes on. `GuestSendFlags`/`GuestReceiveFlags` accept the flag on every host. The debt entry for `MSG_DONTWAIT` states the two remaining differences: the poll and the transfer are two host calls (a second thread can take the data in between), and a `send` larger than the socket buffer can still block where FreeBSD returns a partial count. Fixes #8185 Overlap: `git merge-tree` against the open socket PR #7090 (SCM_RIGHTS on Unix sockets) conflicts in `Udp.cpp`; whichever lands second rebases. `pr_overlap` was not run. ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 7e12b3da80 + this commit: - `guest_udp` and `guest_socket_timeouts`: `Exit code 0xc0000409` without the change to `Udp.cpp`, pass with it. - `guest_socket_options`, `_read_write`, `_event`, `_descriptors`, `_connect_listening`, `_error`, `_stream_options`, `_pair`, `_port_zero`, `_descriptor_flags`, `_host_write` and `guest_sce_net` pass (27 of 27). - `python tools/check_conventions.py --base upstream/main`: passes. - Not tested: Linux/macOS (unchanged paths), a console, a title run. `libSceNet` is not changed and still answers `EOPNOTSUPP` on Windows. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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] Unblocks: none - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-20 02:02:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T02:02:49Z.


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 docs/dev/debt/libkernel.md L176

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 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestUdp.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6519 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6977 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 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 7509 docs/dev/debt/libkernel.md
PR 7554 docs/dev/debt/libkernel.md
PR 7556 docs/dev/debt/libkernel.md
PR 7605 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7949 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281605441 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8186#issuecomment-6281605441). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T02:02:49Z. --- <!-- 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) | `docs/dev/debt/libkernel.md` [L176](https://github.com/boykopovar/AnyPS5/blob/db9fe523101ebde1223442478e179f784f319f97/docs/dev/debt/libkernel.md#L176) | | | 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 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/GuestUdp.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 6519](https://www.github.com/boykopovar/AnyPS5/pull/6519) | `docs/dev/debt/libkernel.md` | | [PR 6740](https://www.github.com/boykopovar/AnyPS5/pull/6740) | `docs/dev/debt/libkernel.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `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 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `docs/dev/debt/libkernel.md` | | [PR 7554](https://www.github.com/boykopovar/AnyPS5/pull/7554) | `docs/dev/debt/libkernel.md` | | [PR 7556](https://www.github.com/boykopovar/AnyPS5/pull/7556) | `docs/dev/debt/libkernel.md` | | [PR 7605](https://www.github.com/boykopovar/AnyPS5/pull/7605) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7949](https://www.github.com/boykopovar/AnyPS5/pull/7949) | `docs/dev/debt/libkernel.md` |
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!8186
No description provided.