소스 검색

Gracefully handle errors in socket creation (#662)

In all other calls, exceptions are handled within the ManagedSocket
class, this can't easily be done here as the exception is thrown from
the constructor, so the exception is handled in ISocket and the correct
error is passed to the application.

This should fix #660
Vudjun 1 년 전
부모
커밋
bc07bc482d
1개의 변경된 파일14개의 추가작업 그리고 5개의 파일을 삭제
  1. 14 5
      src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs

+ 14 - 5
src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs

@@ -101,12 +101,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)
+            {
+                LinuxError errNo = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
+                return WriteBsdResult(context, 0, errNo);
+            }
 
             int newSockFd = _context.RegisterFileDescriptor(newBsdSocket);