From ba5c0cf5d8e4ea27fc62cd181ef65b8ff39f0fd5 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Mon, 12 Dec 2022 14:59:31 +0100 Subject: [PATCH] Bsd: Implement Select (#4017) * bsd: Add gdkchan's Select implementation Co-authored-by: TSRBerry <20988865+tsrberry@users.noreply.github.com> * bsd: Fix Select() causing a crash with an ArgumentException .NET Sockets have to be used for the Select() call * bsd: Make Select more generic * bsd: Adjust namespaces and remove unused imports * bsd: Fix NullReferenceException in Select Co-authored-by: gdkchan --- .../HOS/Services/Sockets/Bsd/BsdContext.cs | 38 +++++- .../HOS/Services/Sockets/Bsd/IClient.cs | 125 +++++++++++++++++- .../Services/Sockets/Bsd/IFileDescriptor.cs | 5 +- .../HOS/Services/Sockets/Bsd/ISocket.cs | 3 +- .../Sockets/Bsd/Impl/EventFileDescriptor.cs | 7 +- .../Impl/EventFileDescriptorPollManager.cs | 13 +- .../Sockets/Bsd/Impl/ManagedSocket.cs | 3 +- .../Bsd/Impl/ManagedSocketPollManager.cs | 60 ++++++++- .../HOS/Services/Sockets/Bsd/Impl/WSAError.cs | 2 +- .../Sockets/Bsd/Impl/WinSockHelper.cs | 7 +- .../Sockets/Bsd/Types/BsdAddressFamily.cs | 4 +- .../Services/Sockets/Bsd/Types/BsdIoctl.cs | 2 +- .../Services/Sockets/Bsd/Types/BsdMMsgHdr.cs | 2 +- .../Services/Sockets/Bsd/Types/BsdMsgHdr.cs | 2 +- .../Services/Sockets/Bsd/Types/BsdSockAddr.cs | 2 +- .../Bsd/Types/BsdSocketCreationFlags.cs | 2 +- .../Sockets/Bsd/Types/BsdSocketFlags.cs | 2 +- .../Sockets/Bsd/Types/BsdSocketOption.cs | 2 +- .../Bsd/Types/BsdSocketShutdownFlags.cs | 2 +- .../Sockets/Bsd/Types/BsdSocketType.cs | 2 +- .../Sockets/Bsd/Types/EventFdFlags.cs | 2 +- .../Sockets/Bsd/Types/IPollManager.cs | 6 +- .../Services/Sockets/Bsd/Types/LinuxError.cs | 2 +- .../Services/Sockets/Bsd/Types/PollEvent.cs | 2 +- .../Sockets/Bsd/Types/PollEventData.cs | 4 +- .../Sockets/Bsd/Types/PollEventTypeMask.cs | 2 +- .../HOS/Services/Sockets/Bsd/Types/TimeVal.cs | 2 +- .../SslService/SslManagedSocketConnection.cs | 1 + 28 files changed, 263 insertions(+), 43 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs index cd78af78bf..a93f176a5d 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs @@ -1,5 +1,8 @@ -using System.Collections.Concurrent; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; +using System; +using System.Collections.Concurrent; using System.Collections.Generic; +using System.Numerics; namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { @@ -41,6 +44,27 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return null; } + public List RetrieveFileDescriptorsFromMask(ReadOnlySpan mask) + { + List fds = new(); + + for (int i = 0; i < mask.Length; i++) + { + byte current = mask[i]; + + while (current != 0) + { + int bit = BitOperations.TrailingZeroCount(current); + current &= (byte)~(1 << bit); + int fd = i * 8 + bit; + + fds.Add(RetrieveFileDescriptor(fd)); + } + } + + return fds; + } + public int RegisterFileDescriptor(IFileDescriptor file) { lock (_lock) @@ -61,6 +85,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } + public void BuildMask(List fds, Span mask) + { + foreach (IFileDescriptor descriptor in fds) + { + int fd = _fds.IndexOf(descriptor); + + mask[fd >> 3] |= (byte)(1 << (fd & 7)); + } + } + public int DuplicateFileDescriptor(int fd) { IFileDescriptor oldFile = RetrieveFileDescriptor(fd); @@ -147,4 +181,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return processContext; } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index ece5375b96..eaf65e4cca 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -1,10 +1,13 @@ using Ryujinx.Common; using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; using Ryujinx.Memory; using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; +using System.Numerics; using System.Runtime.CompilerServices; using System.Text; @@ -202,12 +205,122 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } [CommandHipc(5)] - // Select(u32 nfds, nn::socket::timeout timeout, buffer readfds_in, buffer writefds_in, buffer errorfds_in) -> (i32 ret, u32 bsd_errno, buffer readfds_out, buffer writefds_out, buffer errorfds_out) + // Select(u32 nfds, nn::socket::timeval timeout, buffer readfds_in, buffer writefds_in, buffer errorfds_in) + // -> (i32 ret, u32 bsd_errno, buffer readfds_out, buffer writefds_out, buffer errorfds_out) public ResultCode Select(ServiceCtx context) { - WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP); + int fdsCount = context.RequestData.ReadInt32(); + int timeout = context.RequestData.ReadInt32(); - Logger.Stub?.PrintStub(LogClass.ServiceBsd); + (ulong readFdsInBufferPosition, ulong readFdsInBufferSize) = context.Request.GetBufferType0x21(0); + (ulong writeFdsInBufferPosition, ulong writeFdsInBufferSize) = context.Request.GetBufferType0x21(1); + (ulong errorFdsInBufferPosition, ulong errorFdsInBufferSize) = context.Request.GetBufferType0x21(2); + + (ulong readFdsOutBufferPosition, ulong readFdsOutBufferSize) = context.Request.GetBufferType0x22(0); + (ulong writeFdsOutBufferPosition, ulong writeFdsOutBufferSize) = context.Request.GetBufferType0x22(1); + (ulong errorFdsOutBufferPosition, ulong errorFdsOutBufferSize) = context.Request.GetBufferType0x22(2); + + List readFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(readFdsInBufferPosition, (int)readFdsInBufferSize)); + List writeFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(writeFdsInBufferPosition, (int)writeFdsInBufferSize)); + List errorFds = _context.RetrieveFileDescriptorsFromMask(context.Memory.GetSpan(errorFdsInBufferPosition, (int)errorFdsInBufferSize)); + + int actualFdsCount = readFds.Count + writeFds.Count + errorFds.Count; + + if (fdsCount == 0 || actualFdsCount == 0) + { + WriteBsdResult(context, 0); + + return ResultCode.Success; + } + + PollEvent[] events = new PollEvent[actualFdsCount]; + + int index = 0; + + foreach (IFileDescriptor fd in readFds) + { + events[index] = new PollEvent(new PollEventData { InputEvents = PollEventTypeMask.Input }, fd); + + index++; + } + + foreach (IFileDescriptor fd in writeFds) + { + events[index] = new PollEvent(new PollEventData { InputEvents = PollEventTypeMask.Output }, fd); + + index++; + } + + foreach (IFileDescriptor fd in errorFds) + { + events[index] = new PollEvent(new PollEventData { InputEvents = PollEventTypeMask.Error }, fd); + + index++; + } + + List[] eventsByPollManager = new List[_pollManagers.Count]; + + for (int i = 0; i < eventsByPollManager.Length; i++) + { + eventsByPollManager[i] = new List(); + + foreach (PollEvent evnt in events) + { + if (_pollManagers[i].IsCompatible(evnt)) + { + eventsByPollManager[i].Add(evnt); + } + } + } + + int updatedCount = 0; + + for (int i = 0; i < _pollManagers.Count; i++) + { + if (eventsByPollManager[i].Count > 0) + { + _pollManagers[i].Select(eventsByPollManager[i], timeout, out int updatedPollCount); + updatedCount += updatedPollCount; + } + } + + readFds.Clear(); + writeFds.Clear(); + errorFds.Clear(); + + foreach (PollEvent pollEvent in events) + { + for (int i = 0; i < _pollManagers.Count; i++) + { + if (eventsByPollManager[i].Contains(pollEvent)) + { + if (pollEvent.Data.OutputEvents.HasFlag(PollEventTypeMask.Input)) + { + readFds.Add(pollEvent.FileDescriptor); + } + + if (pollEvent.Data.OutputEvents.HasFlag(PollEventTypeMask.Output)) + { + writeFds.Add(pollEvent.FileDescriptor); + } + + if (pollEvent.Data.OutputEvents.HasFlag(PollEventTypeMask.Error)) + { + errorFds.Add(pollEvent.FileDescriptor); + } + } + } + } + + using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize); + using var writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize); + using var errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize); + + _context.BuildMask(readFds, readFdsOut.Memory.Span); + _context.BuildMask(writeFds, writeFdsOut.Memory.Span); + _context.BuildMask(errorFds, errorFdsOut.Memory.Span); + + WriteBsdResult(context, updatedCount); return ResultCode.Success; } @@ -320,14 +433,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd break; } - // If we are here, that mean nothing was availaible, sleep for 50ms + // If we are here, that mean nothing was available, sleep for 50ms context.Device.System.KernelContext.Syscall.SleepThread(50 * 1000000); } while (PerformanceCounter.ElapsedMilliseconds < budgetLeftMilliseconds); } else if (timeout == -1) { - // FIXME: If we get a timeout of -1 and there is no fds to wait on, this should kill the KProces. (need to check that with re) + // FIXME: If we get a timeout of -1 and there is no fds to wait on, this should kill the KProcess. (need to check that with re) throw new InvalidOperationException(); } else @@ -998,4 +1111,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return WriteBsdResult(context, newSockFd, errno); } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs index 56f67539b3..9d4f81ce21 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IFileDescriptor.cs @@ -1,4 +1,5 @@ -using System; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; +using System; namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { @@ -11,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd LinuxError Write(out int writeSize, ReadOnlySpan buffer); } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ISocket.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ISocket.cs index b4f2bff196..058748685d 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ISocket.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/ISocket.cs @@ -1,4 +1,5 @@ -using System; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; +using System; using System.Net; using System.Net.Sockets; diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs index f84e9b93b1..6514d4855a 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs @@ -1,8 +1,9 @@ -using System; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; +using System; using System.Runtime.InteropServices; using System.Threading; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { class EventFileDescriptor : IFileDescriptor { @@ -149,4 +150,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs index 6501d1117a..e0ab68c623 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptorPollManager.cs @@ -1,8 +1,9 @@ using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; using System.Collections.Generic; using System.Threading; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { class EventFileDescriptorPollManager : IPollManager { @@ -109,5 +110,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return LinuxError.SUCCESS; } + + public LinuxError Select(List events, int timeout, out int updatedCount) + { + // TODO: Implement Select for event file descriptors + updatedCount = 0; + + return LinuxError.EOPNOTSUPP; + } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs index 3db7c2223a..75efc49a1b 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs @@ -1,4 +1,5 @@ using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; using System; using System.Collections.Generic; using System.Diagnostics; @@ -6,7 +7,7 @@ using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { class ManagedSocket : ISocket { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs index 31d93cadf1..1b305dfb77 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocketPollManager.cs @@ -1,8 +1,9 @@ using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; using System.Collections.Generic; using System.Net.Sockets; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { class ManagedSocketPollManager : IPollManager { @@ -117,5 +118,60 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return LinuxError.SUCCESS; } + + public LinuxError Select(List events, int timeout, out int updatedCount) + { + List readEvents = new(); + List writeEvents = new(); + List errorEvents = new(); + + updatedCount = 0; + + foreach (PollEvent pollEvent in events) + { + ManagedSocket socket = (ManagedSocket)pollEvent.FileDescriptor; + + if (pollEvent.Data.InputEvents.HasFlag(PollEventTypeMask.Input)) + { + readEvents.Add(socket.Socket); + } + + if (pollEvent.Data.InputEvents.HasFlag(PollEventTypeMask.Output)) + { + writeEvents.Add(socket.Socket); + } + + if (pollEvent.Data.InputEvents.HasFlag(PollEventTypeMask.Error)) + { + errorEvents.Add(socket.Socket); + } + } + + Socket.Select(readEvents, writeEvents, errorEvents, timeout); + + updatedCount = readEvents.Count + writeEvents.Count + errorEvents.Count; + + foreach (PollEvent pollEvent in events) + { + ManagedSocket socket = (ManagedSocket)pollEvent.FileDescriptor; + + if (readEvents.Contains(socket.Socket)) + { + pollEvent.Data.OutputEvents |= PollEventTypeMask.Input; + } + + if (writeEvents.Contains(socket.Socket)) + { + pollEvent.Data.OutputEvents |= PollEventTypeMask.Output; + } + + if (errorEvents.Contains(socket.Socket)) + { + pollEvent.Data.OutputEvents |= PollEventTypeMask.Error; + } + } + + return LinuxError.SUCCESS; + } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs index d87e72d826..0f24a57f51 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WSAError.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { [SuppressMessage("ReSharper", "InconsistentNaming")] enum WsaError diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs index ad12745e8d..48439d7d31 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs @@ -1,7 +1,8 @@ -using System.Collections.Generic; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; +using System.Collections.Generic; using System.Net.Sockets; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl { static class WinSockHelper { @@ -162,4 +163,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd return table.TryGetValue(option, out name); } } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs index dcc9f0fd7a..37461bb25f 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdAddressFamily.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { enum BsdAddressFamily : uint { @@ -8,4 +8,4 @@ Unknown = uint.MaxValue } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs index 421a255ccb..1dfa5a5f99 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdIoctl.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { enum BsdIoctl { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMMsgHdr.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMMsgHdr.cs index bfcc92cd86..f97b8f5be3 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMMsgHdr.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMMsgHdr.cs @@ -1,6 +1,6 @@ using System; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { class BsdMMsgHdr { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMsgHdr.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMsgHdr.cs index bb620375c7..07c97182c1 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMsgHdr.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMsgHdr.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { class BsdMsgHdr { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs index 71926ceba1..67c11e54de 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs @@ -3,7 +3,7 @@ using System; using System.Net; using System.Runtime.InteropServices; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x10)] struct BsdSockAddr diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs index 77718800d2..be5991ff6f 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketCreationFlags.cs @@ -1,6 +1,6 @@ using System; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { [Flags] enum BsdSocketCreationFlags diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs index ca464c09e4..4408c89af6 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketFlags.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { enum BsdSocketFlags { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs index 726e4111e7..4d0d1dcf3f 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketOption.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { enum BsdSocketOption { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs index 2588376bb9..13230ac395 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketShutdownFlags.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { enum BsdSocketShutdownFlags { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketType.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketType.cs index 9b13e669a6..b54c788633 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketType.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSocketType.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { enum BsdSocketType { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs index 7d08fb24a3..e01d822679 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/EventFdFlags.cs @@ -1,6 +1,6 @@ using System; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { [Flags] enum EventFdFlags : uint diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs index 8b0959fd06..d366387840 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/IPollManager.cs @@ -1,11 +1,13 @@ using System.Collections.Generic; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { interface IPollManager { bool IsCompatible(PollEvent evnt); LinuxError Poll(List events, int timeoutMilliseconds, out int updatedCount); + + LinuxError Select(List events, int timeout, out int updatedCount); } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs index b132698521..96602830b8 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/LinuxError.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { [SuppressMessage("ReSharper", "InconsistentNaming")] enum LinuxError diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs index 8056e7a875..8b77a6c2f5 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEvent.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { class PollEvent { diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs index df084ff4ab..546b738ee1 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventData.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { struct PollEventData { @@ -8,4 +8,4 @@ #pragma warning restore CS0649 public PollEventTypeMask OutputEvents; } -} +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs index 899072bf04..f434fa0321 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/PollEventTypeMask.cs @@ -1,6 +1,6 @@ using System; -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { [Flags] enum PollEventTypeMask : ushort diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/TimeVal.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/TimeVal.cs index c577660235..690a63aeb2 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/TimeVal.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/TimeVal.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd +namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types { public struct TimeVal { diff --git a/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs b/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs index 56bfa709b2..47d3eddbec 100644 --- a/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs +++ b/Ryujinx.HLE/HOS/Services/Ssl/SslService/SslManagedSocketConnection.cs @@ -1,4 +1,5 @@ using Ryujinx.HLE.HOS.Services.Sockets.Bsd; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl; using Ryujinx.HLE.HOS.Services.Ssl.Types; using System; using System.IO;