libkernel: a socket accepted from a non-blocking listener is blocking (FreeBSD inherits the mode); fix branch ready #3938
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 husseinkad on 2026-10-11T19:25:25Z.
accepton a non-blocking listener returns a socket that is blocking:fcntl(F_GETFL)on it shows noO_NONBLOCK, and arecvon it with no data waits instead of returningEWOULDBLOCK. FreeBSD 11.4acceptcallskern_accept4withACCEPT4_INHERIT, which copies the listener's non-blocking flag (SS_NBIO) to the accepted socket. A title that sets its listener non-blocking and then polls the accepted sockets would block inrecvon Windows.Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/kernel-socket-accept-nonblock (one commit on current main,
Socket/src/Udp.cppandtests/GuestTcp.cpp). When the listener is non-blocking, the accepted socket is put in non-blocking mode through the sameSetNonBlockinghelper thatfcntlandioctluse, so the tracked flag thatF_GETFLreads stays consistent. A blocking listener is unchanged.Checks:
guest_tcpcase fails on main (assertion abort) and passes with the change;guest_(tcp|udp|poll|socket|dup)pass.F_GETFLon an accepted socket returns 6 instead of 2 when the listener is non-blocking. An empty non-blocking accept still givesEWOULDBLOCKwith the address buffer untouched;recvon the inherited socket gives 35 when empty; turning the listener back to blocking (byfcntlorFIONBIO, also through a duplicated descriptor) makes later accepts blocking, and an already accepted socket keeps its own mode;pollresults are identical.check_conventions.pyis clean andpr_overlap.pyfinds no overlap (#3592 also editsUdp.cpp, in the error table, so a trivial rebase may be needed).Not covered:
sceNetAcceptinlibSceNet/Export.cpphas its own accept path that does not inherit the mode either. On Linux the host accepted socket is blocking, so the new test would hang there without the fix; only Windows was built and run.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T03:36:16Z.
The accepted-socket inheritance fix from the linked branch is already present on current main
c13dc7e6b440725babd25ccec4262ccc4c78dfc3:accept_nid_postfixcopies the listener nonblocking state and applies it withSetNonBlocking, andguest_tcpincludesAcceptedSocketsFollowListenerBlocking. I builtguest_tcp_testson Linux/GCC 12.2 against this main andctest -R ^guest_tcp$passes (1/1); conventions and test registration also pass. No PR is needed for this issue as currently written. The separatesceNetAcceptpath in #4898 remains a distinct implementation.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T07:37:47Z.
Closing: fixed by #3958. Reopen if an accepted socket still comes back blocking on current main.