Bladeren bron

Fix race in SM initialization (#2280)

gdkchan 5 jaren geleden
bovenliggende
commit
a8022ca3a1
2 gewijzigde bestanden met toevoegingen van 4 en 3 verwijderingen
  1. 1 1
      Ryujinx.HLE/HOS/Horizon.cs
  2. 3 2
      Ryujinx.HLE/HOS/Services/ServerBase.cs

+ 1 - 1
Ryujinx.HLE/HOS/Horizon.cs

@@ -274,7 +274,7 @@ namespace Ryujinx.HLE.HOS
         public void InitializeServices()
         public void InitializeServices()
         {
         {
             IUserInterface sm = new IUserInterface(KernelContext);
             IUserInterface sm = new IUserInterface(KernelContext);
-            sm.TrySetServer(new ServerBase(KernelContext, "SmServer") { SmObjectFactory = () => new IUserInterface(KernelContext) });
+            sm.TrySetServer(new ServerBase(KernelContext, "SmServer", () => new IUserInterface(KernelContext)));
 
 
             // Wait until SM server thread is done with initialization,
             // Wait until SM server thread is done with initialization,
             // only then doing connections to SM is safe.
             // only then doing connections to SM is safe.

+ 3 - 2
Ryujinx.HLE/HOS/Services/ServerBase.cs

@@ -38,13 +38,14 @@ namespace Ryujinx.HLE.HOS.Services
         private readonly Dictionary<int, Func<IpcService>> _ports = new Dictionary<int, Func<IpcService>>();
         private readonly Dictionary<int, Func<IpcService>> _ports = new Dictionary<int, Func<IpcService>>();
 
 
         public ManualResetEvent InitDone { get; }
         public ManualResetEvent InitDone { get; }
-        public Func<IpcService> SmObjectFactory { get; set; }
+        public Func<IpcService> SmObjectFactory { get; }
         public string Name { get; }
         public string Name { get; }
 
 
-        public ServerBase(KernelContext context, string name)
+        public ServerBase(KernelContext context, string name, Func<IpcService> smObjectFactory = null)
         {
         {
             InitDone = new ManualResetEvent(false);
             InitDone = new ManualResetEvent(false);
             Name = name;
             Name = name;
+            SmObjectFactory = smObjectFactory;
             _context = context;
             _context = context;
 
 
             const ProcessCreationFlags flags =
             const ProcessCreationFlags flags =