aboutsummaryrefslogtreecommitdiff
path: root/src/core/internal_network/socket_proxy.h
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-11-03 00:17:34 +0100
committercirakg <cirakg@cirakg.xyz>2026-11-03 00:17:34 +0100
commit78e0a12180a71adf8dffc2c2f6697a0a0735d5ea (patch)
treeaa01f2f66b870d40780f957e97f7a071533e2b5a /src/core/internal_network/socket_proxy.h
parentb233b36862d370d73fe517a1e53c34b50c2845f5 (diff)
network: fix room socket races and share the room network check
bsd:s, bsd:u and bsd:a share one file descriptor table, but each service bound its own proxy packet callback, so every room packet was queued three times on each socket. Bind the callback once. The room thread walked the descriptor table without a lock while bsd created and closed sockets, so it could reach a destroyed or not yet created socket. Guard the table with a mutex, and publish a socket only after it is created and initialized. Check airplane mode before an fd is taken, so a refused socket no longer leaks its slot. ProxySocket now initializes protocol, decompresses packets outside the packet lock without copying the compressed data first, and keeps a read offset for partial TCP reads instead of erasing from the front. Add Network::GetRoomIPv4Address(), set only in the Joined and Moderator states. NIFM uses it for network availability and for every reported address, including EnumerateNetworkInterfaces and GetCurrentIpAddress, so no call reports the room address while another rejects the network. Assisted-by: Claude Opus 5.5 (investigation and implementation)
Diffstat (limited to 'src/core/internal_network/socket_proxy.h')
-rw-r--r--src/core/internal_network/socket_proxy.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/core/internal_network/socket_proxy.h b/src/core/internal_network/socket_proxy.h
index 8343fcbae1..d2bd7aae77 100644
--- a/src/core/internal_network/socket_proxy.h
+++ b/src/core/internal_network/socket_proxy.h
@@ -90,7 +90,8 @@ private:
SockAddrIn local_endpoint{};
bool blocking = true;
std::queue<ProxyPacket> received_packets;
- Protocol protocol;
+ std::size_t front_read_offset = 0; ///< Bytes of the front TCP packet that were already read
+ Protocol protocol{};
std::mutex packets_mutex;
std::condition_variable packets_cv;