fix(libSceNet): read setsockopt timeouts as struct timeval #4371
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4371"
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 milescoviello on 2026-10-12T07:58:36Z.
What
Since #4111, libkernel's
setsockopt()hands options for a libSceNet socket tosceNetSetsockopt(). That function'sSO_RCVTIMEOandSO_SNDTIMEOtake anintof microseconds, but the POSIX call takes astruct timeval, so main reads the low half oftv_secas microseconds:{1, 250000}(1.25 s) sets a 1 µs receive timeout, so every receive fails withEAGAINalmost at once;{0, 500000}(0.5 s) sets 0, which disables the timeout, so a receive that should give up after half a second blocks forever;tv_usecis accepted.FreeBSD reads a
struct timevalfor these options,sys/kern/uipc_socket.c,sosetopt():and
sooptcopyin()rejects a shorter value:setsockopt()on a libSceNet socket now converts thetimevalfor these two options (EINVALfor a value shorter than atimeval,EDOMfor a negative or out-of-range one,EFAULTfor a null value with a length, askern_setsockopt()does) and applies it to the host socket.sceNetSetsockopt()keeps taking microseconds; both paths now share the code that sets the host timeout, andsceNetGetsockopt()reports the timeout either way. No title is claimed.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags.
guest_sce_netsetsSO_RCVTIMEO{1, 250000}andSO_SNDTIMEO{0, 500000}on a libSceNet socket throughsetsockopt()and reads them back withsceNetGetsockopt(); checksEDOMfor{0, 1000000}and{-1, 0}andEINVALfor a 4-byte value, both leaving the timeouts unchanged; checks thatsceNetSetsockopt()still takes anintof microseconds; and, on Linux, that a receive on a bound socket with a{0, 50000}timeout fails withEAGAINafter at least 40 ms.guest_udp,guest_tcp,guest_socket_pair,guest_socket_read_writeandguest_socket_events, and all 297guest_*tests pass (-E '^guest_video_out_').Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T12:20:21Z.
Windows test: head
e9c5ae26bmerged onto currentmainffa198407(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j4: full build 0 errors; ctest with the filterguest_sce_net: guest_sce_net passed (1 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T17:49:28Z.
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.
main)core/libs/prx/libSceNet/Export.cppL323-324