From 931bb2ea12a6545f0da874cc7ca97fef2297a966 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 17 Jul 2011 13:01:37 -0700 Subject: [PATCH] Fixed process priority correction. --- NzbDrone.Web/NzbDrone.Web.csproj | 10 ++++++---- NzbDrone/IISController.cs | 3 ++- NzbDrone/Program.cs | 28 +++++++++++++++++++--------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 0d6a9a2b6..2874ee488 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -184,13 +184,15 @@ - + - + - - + + + + diff --git a/NzbDrone/IISController.cs b/NzbDrone/IISController.cs index d85262510..fcc4018e8 100644 --- a/NzbDrone/IISController.cs +++ b/NzbDrone/IISController.cs @@ -65,8 +65,9 @@ namespace NzbDrone Logger.Info("Starting process. [{0}]", IISProcess.StartInfo.FileName); - IISProcess.PriorityClass = ProcessPriorityClass.AboveNormal; + IISProcess.Start(); + IISProcess.PriorityClass = ProcessPriorityClass.AboveNormal; IISProcess.BeginErrorReadLine(); IISProcess.BeginOutputReadLine(); diff --git a/NzbDrone/Program.cs b/NzbDrone/Program.cs index 0eea8feef..deb6c13ab 100644 --- a/NzbDrone/Program.cs +++ b/NzbDrone/Program.cs @@ -64,25 +64,35 @@ namespace NzbDrone Console.ReadLine(); } - static void prioCheckTimer_Elapsed(object sender, ElapsedEventArgs e) + private static void prioCheckTimer_Elapsed(object sender, ElapsedEventArgs e) { Process currentProcess = Process.GetCurrentProcess(); - if (currentProcess.PriorityClass < ProcessPriorityClass.Normal) + if (currentProcess.PriorityClass != ProcessPriorityClass.Normal) { - Logger.Info("Promoting Nzbdrone.exe process priority from {0} to {1}", currentProcess.PriorityClass, - ProcessPriorityClass.Normal); - currentProcess.PriorityClass = ProcessPriorityClass.Normal; + SetPriority(currentProcess); } - if (IISController.IISProcess != null && IISController.IISProcess.PriorityClass < ProcessPriorityClass.Normal) + if (IISController.IISProcess != null) { - Logger.Info("Promoting IISExpress process priority from {0} to {1}", IISController.IISProcess.PriorityClass, - ProcessPriorityClass.Normal); - IISController.IISProcess.PriorityClass = ProcessPriorityClass.Normal; + IISController.IISProcess.Refresh(); + + if (IISController.IISProcess.PriorityClass != ProcessPriorityClass.Normal && IISController.IISProcess.PriorityClass != ProcessPriorityClass.AboveNormal) + { + SetPriority(IISController.IISProcess); + } } } + private static void SetPriority(Process process) + { + Logger.Info("Updating [{0}] process priority from {1} to {2}", + process.ProcessName, + IISController.IISProcess.PriorityClass, + ProcessPriorityClass.Normal); + process.PriorityClass = ProcessPriorityClass.Normal; + } + #if DEBUG