Skip to content

Commit

Permalink
Fix process affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
Alpha5k committed May 21, 2024
1 parent c7e0594 commit 094be5f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions SWBF2Admin/Gameserver/ServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,8 @@ private bool Attach(bool starting)
}
if (Core.Config.SetAffinity)
{
var threads = serverProcess.Threads;
foreach (ProcessThread thread in threads)
{
thread.ProcessorAffinity = Core.Config.ProcessAffinity;
}
serverProcess.ProcessorAffinity = (IntPtr)Core.Config.ProcessAffinity;
Logger.Log(LogLevel.Info, "Process Affinity: 0x{0}", serverProcess.ProcessorAffinity.ToString("X"));
}
return true;
}
Expand Down Expand Up @@ -203,12 +200,7 @@ public void Start()
serverProcess = Process.Start(startInfo);
serverProcess.EnableRaisingEvents = true;
serverProcess.Exited += new EventHandler(ServerProcess_Exited);
if (Core.Config.EnableHighPriority)
{
serverProcess.PriorityClass = ProcessPriorityClass.High;
}
}
, 5000);
}, 5000);
status = ServerStatus.SteamPending;
}
else
Expand All @@ -220,7 +212,11 @@ public void Start()
{
serverProcess.PriorityClass = ProcessPriorityClass.High;
}

if (Core.Config.SetAffinity)
{
serverProcess.ProcessorAffinity = (IntPtr)Core.Config.ProcessAffinity;
Logger.Log(LogLevel.Info, "Process Affinity: 0x{0}", serverProcess.ProcessorAffinity.ToString("X"));
}
status = ServerStatus.Online;
InvokeEvent(ServerStarted, this, new StartEventArgs(false));
InjectRconDllIfRequired();
Expand Down

0 comments on commit 094be5f

Please sign in to comment.