Repository navigation
feat(libkernel): answer TCP_NODELAY, SO_NOSIGPIPE and SO_NBIO on a guest socket - #5565
Conversation
|
Evidence for head Which catalog titles ask for the three options
Method: the 65 release archives listed in ps5-homebrew-catalog were downloaded (SHA-256 equal to the catalog records); 63 of them hold an TestsWindows: guest_socket_stream_options, 20 repeated runsWindows: the nine socket tests (guest_udp times out on this machine with main's Udp.cpp too, see the control)Windows control: Udp.cpp from main, new testLinux: the ten socket testsLinux control: Udp.cpp from main, new testThe two controls were run on AI-assisted (Claude Code). |
|
The PR overlap check lists four open pull requests against this one, so the checklist declares the order
If one of you prefers this PR first, say so and I drop that number from the line. AI-assisted (Claude Code). |
adriadam10
left a comment
There was a problem hiding this comment.
#4796 is merged, so this needs a rebase and a port before it can land:
setsockopt/getsockopton main now delegate toGuestSockets::SetSocketLevelOption/GetSocketLevelOptioninSocket/src/SocketOptions.cpp, with the per-socket state inSocket::optionsundermodeMutex(Udp.cppsetsockopt_nid_postfix).Udp.cppconflicts on exactly those lines. Please moveSO_NOSIGPIPE,SO_NBIOand theIPPROTO_TCPhandling into that structure (theSO_NOSIGPIPEflag belongs inSocketOptionState, not a separate atomic read outside the lock) instead of a second dispatcher in front of it.core/libs/tests/GuestSocketOptions.cpp:155on main expectsSO_NOSIGPIPE(0x800) to fail; it has to change with this behaviour, and your new test should keep passing next to it.- Keep the
acceptinheritance and theMSG_NOSIGNALonsend/sendto/write; those parts look right againstkern_sendit/sonewconn. - Docs:
docs/dev/debt/libkernel.mdconflicts with main; "Depends on: #4796, #4903, #4920, #5403" no longer matches (#4796 and #4903 merged, #4920 and #5403 closed). Update it to what is actually open.
Once it is rebased on current main with guest_socket_stream_options and guest_socket_options passing, it should be ready for another look.
36ff565 to
1e47835
Compare
|
@adriadam10 ported to
Results at
#5617 is rebased onto this commit. AI-assisted (Claude Code). |
…est socket Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1e47835 to
7e79f36
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Re-checked on the current head, merged onto main:
- Ported into
SocketOptionStateundermodeMutex; no second dispatcher inUdp.cpp. guest_socket_optionsupdated forSO_NOSIGPIPE;guest_socket_optionsandguest_socket_stream_optionspass, and both fail with theSocketOptions/Udp.cppchanges reverted.acceptinheritance andMSG_NOSIGNALonsend/sendto/writekept; debt doc matches what is open.
Merging once the full Build is green.
|
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.
|
|
Cross-validation on Windows 11 Pro 26220, NVIDIA RTX 4070 (596.21), MinGW GCC 15.2, PR head This ran after the merge ( ProsperoRadio (PPSA99001)
VITA5 (PPSA39410)
ProsperoStore (PPSA99000)
No run had a stop line. Tests
Suite. Conventions. Review. The FreeBSD links are pinned to Written with Claude Code assistance. |
…Setsockopt The call MXGP 26 makes; libkernel answers it since boykopovar#5565. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Setsockopt The call MXGP 26 makes; libkernel answers it since boykopovar#5565. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
setsockoptandgetsockopton a socket fromsocket()answer the SOL_SOCKET options #4796 added and fail every other option and level withENOPROTOOPT. This PR answers three more, the ones the discussion of #4796 left as a separate change. They are added to #4796's structure: the handling is inSocket/src/SocketOptions.cpp, and the per-socket state is inSocketOptionStateundermodeMutex.TCP_NODELAY(IPPROTO_TCP, 1) is set on the host socket and reads back asTF_NODELAY(4), as FreeBSD 11.4'stcp_default_ctloutputreturns it. TheIPPROTO_TCPlevel on a datagram orAF_UNIXsocket fails withEINVAL, asip_ctloutputanduipc_ctloutputanswer it. Every other TCP option still fails withENOPROTOOPT.setsockoptandgetsockoptpass level 6 to the newSetTcpLevelOptionandGetTcpLevelOption, and SOL_SOCKET to the existing functions.SO_NOSIGPIPE(0x800) is kept inSocketOptionState::noSignaland reads back as its own bit (sogetopt). It takes effect: on Linux asend,sendto,sendmsgorwriteon that socket passesMSG_NOSIGNALto the host, so a broken connection givesEPIPEwithout the host'sSIGPIPEending the title, askern_senditandsoo_writedecide it.sendandsendtoread the flag undermodeMutex;sendmsgandwritego through them. An accepted socket takes the option from its listener, assonewconncopies the options. Windows raises no signal either way.SO_NBIO(0x1200), the console's own non-blocking option, switches the host socket withFIONBIOand reads back as 0 or 1, assceNetSetsockoptandsceNetGetsockopttreat it here. The non-blocking flag moves fromSocketintoSocketOptionState, so this option,fcntl,ioctl(FIONBIO)andacceptuse the same state.SocketOptions.cpp. A value shorter than anintfails withEINVAL(sooptcopyin), and so does a null value.getsockoptcopies as many bytes as the buffer holds. FreeBSD'skern_setsockoptreturnsEFAULTfor a null value instead; that applies to every option here and is recorded in the debt entry rather than changed.guest_socket_optionsexpectedSO_NOSIGPIPEto fail. It now checks that the option reads back as its bit. The debt entry forSocketOptions.cppand the sentence onSIGPIPEin the socket read/write entry are updated.Titles that ask for them:
SO_NBIOon every curl socket and fails the request when the call fails; VITA5 (PPSA39410) returns the error of the same call. Onmainthe call fails withENOPROTOOPT. This is read from their sources; neither title was run.TCP_NODELAY,SO_NOSIGPIPEand option0x1200failing withENOPROTOOPTonmain; curl carries on without them.TCP_NODELAYis set by 29 titles,SO_NOSIGPIPEby 28,SO_NBIOby 18 and read by 12. The level and option were recovered at 840 of 2661setsockoptcall sites, so these are lower bounds. The lists and the method are in this comment.Related:
F_GETFDandF_SETFDin front of theF_GETFLline offcntl. This branch is rebased onto it, and that line reads the flag fromSocketOptionState.SO_SNDTIMEOandSO_RCVTIMEOto the same structure.Tested
Windows 11, Ryzen 7 5800H, WinLibs MinGW-w64 GCC 15.2.0 r7; Ubuntu 26.04 under WSL, GCC 15.2.0. Release,
BUILD_TESTING=ON, root configuration withFFMPEG_PREBUILT_DIRpointed at an already unpacked package. Head7e79f36edonmain4c1de0c0c.guest_socket_stream_optionscovers the three options on a loopback TCP pair, a datagram socket and anAF_UNIXpair. It checks values and read-back, short and truncated arguments, and theEINVALof the TCP level on the other socket kinds. It also checksEAGAINfrom a receive afterSO_NBIOandF_GETFLfollowing it, inheritance by an accepted socket, andEPIPEfromsendandwriteaftershutdown(SHUT_WR). On Linux it counts hostSIGPIPEdeliveries: none whileSO_NOSIGPIPEis set orMSG_NOSIGNALis passed, and one after the option is cleared.SocketOptions.hpp,SocketOptions.cppandUdp.cppfrommainand the tests of this PR,guest_socket_stream_optionsfails on both systems withsocket stream option check failed at line 91, errno 42.guest_socket_optionsfails withsetsockopt of an integer option failed (errno 42).guest_socket_stream_optionsandguest_socket_optionspass 20 of 20 repeated runs. Of the twelve socket tests eleven pass.guest_udptimes out after 20 s, and does so onmaintoo: on this machine a datagram to[::1]is never delivered, even between two plain host sockets outside AnyPS5.guest_udpincluded.git diff --checkpass.Not tested: any title, a console, macOS, the full test suite. Full PR builds need a collaborator's manual Build run.
Checklist
main; no other open PR implements these three options.mdfiles or images added to the repository🤖 Generated with Claude Code