From b1bd6a50b5341f444ceb31bbb0fb64f685828d75 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 12 Jun 2022 04:29:12 -0300 Subject: [PATCH] Less invasive fix for EventFd blocking operations (#3394) --- Ryujinx.HLE/HOS/Horizon.cs | 2 +- Ryujinx.HLE/HOS/Services/ServerBase.cs | 26 +------------------ .../Sockets/Bsd/Impl/EventFileDescriptor.cs | 5 ++++ 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index 2e64542e5f..b93ebc0329 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -309,7 +309,7 @@ namespace Ryujinx.HLE.HOS // only then doing connections to SM is safe. SmServer.InitDone.WaitOne(); - BsdServer = new ServerBase(KernelContext, "BsdServer", null, 2); + BsdServer = new ServerBase(KernelContext, "BsdServer"); AudRenServer = new ServerBase(KernelContext, "AudioRendererServer"); AudOutServer = new ServerBase(KernelContext, "AudioOutServer"); FsServer = new ServerBase(KernelContext, "FsServer"); diff --git a/Ryujinx.HLE/HOS/Services/ServerBase.cs b/Ryujinx.HLE/HOS/Services/ServerBase.cs index 2aead42e3d..c13ee1863c 100644 --- a/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -42,15 +42,12 @@ namespace Ryujinx.HLE.HOS.Services public string Name { get; } public Func SmObjectFactory { get; } - private int _threadCount; - - public ServerBase(KernelContext context, string name, Func smObjectFactory = null, int threadCount = 1) + public ServerBase(KernelContext context, string name, Func smObjectFactory = null) { InitDone = new ManualResetEvent(false); _context = context; Name = name; SmObjectFactory = smObjectFactory; - _threadCount = threadCount; const ProcessCreationFlags flags = ProcessCreationFlags.EnableAslr | @@ -86,27 +83,6 @@ namespace Ryujinx.HLE.HOS.Services private void Main() { - for (int i = 1; i < _threadCount; i++) - { - KernelResult result = _context.Syscall.CreateThread(out int threadHandle, 0UL, 0UL, 0UL, 44, 3, ServerLoop); - - if (result == KernelResult.Success) - { - result = _context.Syscall.StartThread(threadHandle); - - if (result != KernelResult.Success) - { - Logger.Error?.Print(LogClass.Service, $"Failed to start thread on {Name}: {result}"); - } - - _context.Syscall.CloseHandle(threadHandle); - } - else - { - Logger.Error?.Print(LogClass.Service, $"Failed to create thread on {Name}: {result}"); - } - } - ServerLoop(); } diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs index ea63e84254..239e2434c2 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/EventFileDescriptor.cs @@ -18,6 +18,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public EventFileDescriptor(ulong value, EventFdFlags flags) { + // FIXME: We should support blocking operations. + // Right now they can't be supported because it would cause the + // service to lock up as we only have one thread processing requests. + flags |= EventFdFlags.NonBlocking; + _value = value; _flags = flags;