Repository navigation
fix(net): keep MSG_DONTWAIT transfers nonblocking on Windows - #8653
Conversation
|
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.
|
|
Independent Windows run of this PR. Environment: Windows 11 10.0.26300 (same build as the PR description), Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON. I built only Results:
Not run: other platforms, the SSL provider tests, the full repository CTest, and any title or console run. AI-assisted: yes |
|
@Ondra97 Thanks. The race is real, the per-call One request, about blocking sends now that the native socket is always non-blocking. In Could the blocking stream path (no A smaller point, not a blocker: every thread blocked in a receive now wakes every 10 ms to notice a local close. A one-line debt note about the polling interval would help whoever looks at idle CPU later. After that, the bar is a full CI run with the |
|
@oneandonlydean I fixed the blocking stream path in c415375041. It advances through short host writes with one deadline for the whole call, returns queued bytes on timeout or error, and returns The three new send/sendto/sendmsg tests use a real TCP loopback reader and a 4 MiB patterned payload. Test-only Windows wrappers cap each actual host send at 16 KiB, since small socket buffers alone did not reliably force a short write here. The original-head/current-main composition returns only 16 KiB in all three cases; the fix returns and delivers all 4 MiB. Timeout with and without progress, local abort, and guest nonblocking mode also pass. All 11 The full Windows build completes with the already-declared #8310 test-only dependency, restored afterwards. The focused suite is 54/55 with no skips, including both SSL transport providers; |
What
On Windows, the readiness check before a
MSG_DONTWAITreceive could succeed in several threads, then one reader consumed the available byte and another entered a blocking Winsock receive. The regression reproduces this forsceNetRecv,sceNetRecvfromandsceNetRecvmsgon TCP loopback.Native Net sockets now stay non-blocking. Transfers return immediately for
MSG_DONTWAITor guestSO_NBIO; ordinary operations retry after readiness until their existing timeout. Blocking stream sends advance through short host writes until the whole buffer is queued. A timeout or host error after progress returns the queued count; a send timeout without progress returnsEAGAIN. The original deadline is shared across all partial writes. Blocking connect and accept keep their waiting behavior. Readiness waits retry at most every 10 ms so local shutdown is observed even when Winsock does not wakeWSAPoll.The existing native-socket owner carries an optional provider transfer callback. SSL uses it for Net sockets, retaining the socket's lifetime, current guest mode and timeouts without changing the lookup signature or the SSL session constructor. Kernel sockets retain their existing direct native transport.
The blocking stream completion follows FreeBSD 11.4 sosend_generic. The per-call contract follows FreeBSD recv(2); Winsock documents the socket-wide mode in ioctlsocket. This addresses a host defect identified in the PRAGMATA audit in #8005; it does not establish a game blocker or fix that whole issue.
Tested
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 UCRT r7, Release,
BUILD_TESTING=ON. AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER; GPU unused.Main base:
5b59fbc5539b6c6db7a26972f6069f1c6cc179ac. Tested code head:c415375041b70c7ea4c127b0b8016892903c7b91. Documentation-only follow-up:401dee24b6dbfc4d3da865dac59c15ab9d2762af; onlydocs/dev/debt/libSceNet.mdchanged after validation. Runtime and test sources are identical.The initial comparison used base
2185dbf92e8d9013a1620d2dfc95de50494e19f8and original headf29c50766892775df90c689031975e3f432f35f4. The same eight syntheticnet_dontwait_*cases have 4 failures on the base and 0 after the fix: the three competing-reader cases and the pending receive after local close fail on the base. Each reader case runs 32 races with eight readers competing for one byte. Send/sendto/sendmsg and duplex controls also check delivered bytes and unchanged guest blocking flags. A full send is permitted when Winsock accepts the entire buffer.Three new
net_dontwait_blocking_send,_sendtoand_sendmsgtests send a patterned 4 MiB payload to a real loopback reader that drains slowly and verifies every byte. On Windows, test-only wrappers limit each real hostsend/sendtoto 16 KiB to make short writes deterministic. Linux uses the native calls without this limit. Small Winsock buffers alone did not reliably force short writes on this host. The same tests also check a partial count at the original send deadline,EAGAINwithout progress, preserved progress on local abort, and a single host result for guestSO_NBIO.The baseline is the original PR head
f29c507668composed with main5b59fbc553, using the same new test source. Each API returns only 16 KiB there; all three tests fail. After the fix, each returns and delivers the full 4 MiB. These are correctness results with controlled host chunk sizes, not a throughput benchmark.ca55e46f98ad85861dd7567abad0c028274daca1, applied temporarily. Without it, the unchanged main fileImageArrayWindowPastLayerLimit.cppfails atalignas(65536)because WinLibs supports at most 8192 for a static object. The file's baseline blob is0d29ae08e46e33c1cd0e931f951befcf42961ec5. The dependency file was restored byte-for-byte and is absent from this PR. The full build is therefore validation with that dependency, not a passing standalone build without it.net_dontwait_*cases, existing Net/NetCtl/UDP/descriptor/option/select/guest-buffer tests, both SSL transport providers and patched-library loading (354 libraries, zero load failures).guest_pollstill aborts on this host in its urgent-TCP priority wait atGuestPoll.cpp:202. I reproduced the same assertion with the original mainSocketPoll.hppandUdp.cpp, using the same test source and host; both runs fail after the outside peer sendsMSG_OOB. A temporary source-location diagnostic identified line 204 with its two added includes (original line 202), and every diagnostic file was restored. The test remains enabled and unchanged. This is a reproduced baseline failure, not a passing test or a demonstrated regression of this change; the complete suite command below exits with status 8 because of it.guest_poll. The independent run in the comments passedguest_pollon another Windows host; I do not count that as a pass for this updated head.python tools/check_conventions.py --base origin/main,python tools/check_test_registration.py ../buildandgit diff --checkpass.python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/fix-net-dontwaitreports an adjacent debt-text conflict with fix(libSceNet): retire invalidated epoll registrations #8598, so I list it first in the merge order. The epoll and transfer implementations are independent. I manually inspected the shared-file patches the checker could not compare in feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, fix(libSceNet): stop Sackboy loading retries on peer sockets #5836, test: organize library tests and label CTest suites #6044, feat(wasm): run relinked titles in the browser with WebGPU #6879, feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) #6977, feat(libkernel): support kevent read and write events on regular files #7088, Macos port #7201 and feat(net): parse Ethernet address strings #8204; none implements this transport fix. fix(ssl): release connections when their context terminates #8541 and feat(prx): declare the missing PS5 3.20 system exports in the next tier of libraries #8431 touch separate SSL paths.Reproduction commands (with the supported toolchain on
PATH):No game or original console module was run. Console ordering between competing operations remains unmeasured, and the existing Windows stream-receive timeout error mapping remains documented debt. The 10 ms readiness polling interval is also recorded in the library debt.
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)