Repository navigation
fix(libSceNet): close a libkernel socket through sceNetSocketClose - #6140
Conversation
dac26a7 to
9c24e86
Compare
|
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.
|
9c24e86 to
1c65051
Compare
|
Checked build and ctest (guest_sce_net passes; it fails when Export.cpp is reverted), the lock ordering (fallback runs after |
MXGP 26 (PPSA30839) opens TCP sockets with libkernel's socket() and later closes them with sceNetSocketClose. libSceNet only looked in its own socket table, so every one of those closes failed with SCE_NET_ERROR_EBADF and the host socket stayed open. On the console both calls work on the same kernel sockets. A descriptor libSceNet does not own but libkernel has open as a socket is now closed through libkernel's close(). Anything else still fails with EBADF. The fallback runs after g_mutex is released, because libkernel's close() first asks libSceNet's socket closer, which takes it. guest_sce_net closes a libkernel TCP socket with sceNetSocketClose, checks that libkernel no longer has it open, and checks that a second close fails with EBADF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1c65051 to
8b81fa0
Compare
|
@adriadam10, I rebased this onto AI-assisted: yes (Claude Code) |
|
Merged while @adriadam10 is away: the review passed and full CI is green on this head. |
What
MXGP 26: The Official Game (PPSA30839) opens TCP sockets with libkernel's
socket(), then closes them withsceNetSocketClose.sceNetSocketCloseonly looked in libSceNet's own socket table, so it failed every one of those closes withSCE_NET_ERROR_EBADF(0x80410109), and the host socket stayed open. On the console, libSceNet's calls and libkernel's socket calls work on the same kernel sockets.Now, when
sceNetSocketClosegets a descriptor that libSceNet doesn't own but libkernel has open as a socket (GuestSocketIsOpen_nid_no_patch), it closes it through libkernel'sclose(). Any other descriptor still fails withEBADF, as before.The fallback runs after
g_mutexis released. libkernel'sclose()first asks libSceNet's registered socket closer, and that closer takesg_mutex.guest_sce_netgains a check:socket()and closes it withsceNetSocketClose;sceNetSocketClosefails withEBADF.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on
maineea428c:guest_sce_netaborts withmain'sExport.cppand passes with the change.guest_*tests pass.tools/check_conventions.py --base upstream/mainpasses.--to-intel, 90 s, every libSceNet socket call traced under gdb:main,sceNetSocketClosereturns0x80410109for descriptors 7, 9 and 11. 7 and 9 came from libkernel'ssocket(2, 1, 0).sceNetSetsockopt(11, IPPROTO_TCP, TCP_NODELAY)still fails withEBADF. Setting options on a libkernel socket through libSceNet is a separate change, and feat(libkernel): answer TCP_NODELAY, SO_NOSIGPIPE and SO_NBIO on a guest socket #5565 coversTCP_NODELAYon libkernel sockets.Not checked on a console.
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