From 52736269d714f714f877f5d928158db312a60fa9 Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:50:04 +0200 Subject: [PATCH] Make _proxyEndpoints thread-safe --- .../HOS/Services/Sockets/Bsd/Proxy/ProxyManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/ProxyManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/ProxyManager.cs index c5a0b5ed3..db827500c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/ProxyManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/ProxyManager.cs @@ -1,4 +1,5 @@ using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Net; using System.Net.Sockets; @@ -8,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy { public static class ProxyManager { - private static readonly Dictionary _proxyEndpoints = new(); + private static readonly ConcurrentDictionary _proxyEndpoints = new(); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static string GetKey(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) @@ -46,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy public static bool Remove(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) { - return _proxyEndpoints.Remove(GetKey(addressFamily, socketType, protocolType)); + return _proxyEndpoints.Remove(GetKey(addressFamily, socketType, protocolType), out _); } } }