Service: BSD: Fix race condition between socket closure and packet reception #96
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bsd-socket"
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?
This change introduces a mutex to synchronize access to the file descriptor table within the BSD service. Previously, a data race existed between the Network thread (distributing incoming packets) and the IPC thread (cleaning up or resetting sockets during closure).
When backing out of a multiplayer lobby or when a communication error occured in certain titles, the game would frequently close sockets while packets were still being processed. Without synchronization, the network thread could attempt to access a socket pointer at the same moment it was being reset, leading to corrupted state and guest-side null pointer dereferences (PC=0).
Additionally, ProxySocket::Close now flushes its internal packet queue to ensure no stale data is processed for a closed descriptor, and the destruction logic in CloseImpl is now atomic relative to the packet reception loop.