From 72ccda2a0ad6c524b584872901df5be9ba771f0b Mon Sep 17 00:00:00 2001 From: Vudjun Date: Fri, 14 Feb 2025 21:10:23 +0000 Subject: [PATCH 1/2] Gracefully handle errors in socket creation --- .../HOS/Services/Sockets/Bsd/IClient.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index 8475424ce..c1712429a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -95,12 +95,21 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId) - { - Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking), - }; - LinuxError errno = LinuxError.SUCCESS; + ISocket newBsdSocket; + + try + { + newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId) + { + Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking), + }; + } + catch (SocketException exception) + { + var errNo = WinSockHelper.ConvertError((WsaError)exception.ErrorCode); + return WriteBsdResult(context, 0, errno); + } int newSockFd = _context.RegisterFileDescriptor(newBsdSocket); From 2596c418324fd6e37b85365832a234ba0ff94214 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sat, 15 Feb 2025 20:58:35 -0600 Subject: [PATCH 2/2] var usage --- src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index c1712429a..3585ef058 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -107,8 +107,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } catch (SocketException exception) { - var errNo = WinSockHelper.ConvertError((WsaError)exception.ErrorCode); - return WriteBsdResult(context, 0, errno); + LinuxError errNo = WinSockHelper.ConvertError((WsaError)exception.ErrorCode); + return WriteBsdResult(context, 0, errNo); } int newSockFd = _context.RegisterFileDescriptor(newBsdSocket);