From ff91b6c0a9e58ff626bbbe80de18acfc97e6641a Mon Sep 17 00:00:00 2001 From: Sparronator9999 <86388887+Sparronator9999@users.noreply.github.com> Date: Sun, 8 Sep 2024 08:16:27 +1000 Subject: [PATCH] Attempt to fix service "soft crashes", part 2 --- YAMDCC.Service/svcFanControl.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/YAMDCC.Service/svcFanControl.cs b/YAMDCC.Service/svcFanControl.cs index a8720aa..17a14b4 100644 --- a/YAMDCC.Service/svcFanControl.cs +++ b/YAMDCC.Service/svcFanControl.cs @@ -455,6 +455,11 @@ private int WriteECByte(string name, string args) private int GetFanSpeed(string name, string args) { + if (!ConfigLoaded) + { + return 0; + } + if (ParseArgs(args, 1, out int[] pArgs)) { if (EC.AcquireLock(1000)) @@ -481,6 +486,11 @@ private int GetFanSpeed(string name, string args) private int GetFanRPM(string name, string args) { + if (!ConfigLoaded) + { + return 0; + } + if (ParseArgs(args, 1, out int[] pArgs)) { FanConf cfg = Config.FanConfs[pArgs[0]]; @@ -548,6 +558,11 @@ private int GetFanRPM(string name, string args) private int GetTemp(string name, string args) { + if (!ConfigLoaded) + { + return 0; + } + if (ParseArgs(args, 1, out int[] pArgs)) { if (EC.AcquireLock(1000)) @@ -573,7 +588,7 @@ private int GetTemp(string name, string args) private int SetFullBlast(string name, string args) { - if (Config.FullBlastConf is not null) + if (ConfigLoaded && Config.FullBlastConf is not null) { if (ParseArgs(args, 1, out int[] pArgs)) { @@ -609,7 +624,7 @@ private int SetFullBlast(string name, string args) private int GetKeyLightBright(string name) { - if (Config.KeyLightConf is null) + if (!ConfigLoaded || Config.KeyLightConf is null) { return 0; } @@ -636,7 +651,7 @@ private int GetKeyLightBright(string name) private int SetKeyLightBright(string name, string args) { - if (Config.KeyLightConf is null) + if (!ConfigLoaded || Config.KeyLightConf is null) { return 0; }