fix(libkernel): set and read SO_LINGER in seconds on macOS #19488
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19488"
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 imellag on 2026-11-13T12:13:50Z.
What
On macOS a guest
SO_LINGERtime was passed to the host'sSO_LINGER, which XNU counts in 1/100 s, not in seconds as FreeBSD does. A title that asked to linger 5 seconds on close got 50 ms. XNU also keeps the time in ashort, so above 32767 (ticks) the set failed withEDOM, which is whyguest_sce_net_lingerfails on macOS at the 65535 s case.Measured on macOS 27.2 (x86-64 under Rosetta 2) with a small native program:
SO_LINGERreadsSO_LINGER_SECreadsSO_LINGERSO_LINGER_SECSO_LINGER_SECSO_LINGER_SECEDOMSO_LINGEREDOMChanges:
setsockoptandgetsockoptofSO_LINGER(andsceNetSetsockopt/sceNetGetsockopt, which share the code) useSO_LINGER_SEC, which is in seconds. Linux and Windows are unchanged.NotImplemented_nid_no_patchinstead of setting a shorter time or failing with an error FreeBSD does not give. The existing checks are unchanged: a negative time or one above 65535 still fails withEDOM, a short value withEINVAL.guest_sce_net_lingerreads the native value withSO_LINGER_SECon macOS, checks 327 s there, and checks that 65535 s throws; elsewhere it is unchanged.libkernel.md.Tested
macOS 27.2, Apple M4 Pro, x86-64 build under Rosetta 2,
maind4556df8a8:guest_sce_net_linger:mainfails (check failed at line 83, the 65535 s set); this PR passes.guest_socket_options(itsLingerFollowsFreeBsdsets 5 s and reads it back): onmainand on this PR alone it stops earlier, at the refused reconnect that #17879 fixes. With #17879 applied on top of this PR it passes in full.guest_ssl_transport_kernel,guest_ssl_transport_net,guest_http2_transport,guest_socket_options_multicast: pass.Not run on Linux or Windows; their code paths are unchanged.
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)