Make _proxyEndpoints thread-safe

This commit is contained in:
TSR Berry 2024-09-24 15:50:04 +02:00
parent 44b81ba59e
commit 52736269d7
No known key found for this signature in database
GPG Key ID: 52353C0A4CCA15E2

View File

@ -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<string, EndPoint> _proxyEndpoints = new();
private static readonly ConcurrentDictionary<string, EndPoint> _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 _);
}
}
}