aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/service/sockets/bsd.h
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-11-03 01:15:29 +0100
committercirakg <cirakg@cirakg.xyz>2026-11-03 01:15:29 +0100
commitd6b32aac3c75a6a0c4190a8b6b2b1fbc5f3e8801 (patch)
treed31c2c69918784470e2b7083d1d9b37b5d011d69 /src/core/hle/service/sockets/bsd.h
parent5979ca6569f3db076bbcb7808bea6a41a5b6928c (diff)
network: keep fcntl modes across MSG_DONTWAIT and decompress room packets once
A receive with MSG_DONTWAIT restored the blocking mode from the descriptor copy taken before the call. When fcntl(SETFL, O_NONBLOCK) ran during the receive, the fd kept reporting O_NONBLOCK while its socket blocked again. Receives now switch the mode only for MSG_DONTWAIT and read the current flags under file_descriptors_mutex at both ends, and SETFL changes the mode and the stored flags in the same critical section. OnProxyPacketReceived decompressed each room packet once per matching socket while holding file_descriptors_mutex, so every bsd call waited for it. It now copies the distinct sockets under the lock, decompresses once without it and delivers the result. Also reject fd == MAX_FD in IsFileDescriptorValid and PollImpl, which read past the table, and guard the ProxySocket blocking and receive timeout setters with packets_mutex, matching their reader. Assisted-by: Claude Opus 5.5 (investigation and implementation)
Diffstat (limited to 'src/core/hle/service/sockets/bsd.h')
-rw-r--r--src/core/hle/service/sockets/bsd.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/core/hle/service/sockets/bsd.h b/src/core/hle/service/sockets/bsd.h
index f908edc7d2..559830d7a1 100644
--- a/src/core/hle/service/sockets/bsd.h
+++ b/src/core/hle/service/sockets/bsd.h
@@ -180,6 +180,8 @@ private:
bool IsFileDescriptorValid(s32 fd) const noexcept;
/// Copies a descriptor under file_descriptors_mutex; nullopt if fd has no socket
std::optional<FileDescriptor> CopyDescriptor(s32 fd);
+ /// Switches a blocking socket for one MSG_DONTWAIT call; false if fd is already nonblocking
+ bool SetDontWait(s32 fd, const FileDescriptor& descriptor, bool enable);
void BuildErrnoResponse(HLERequestContext& ctx, Errno bsd_errno) const noexcept;