From 20a14b1f4986f9c4862f2ab108a93d7d73b1104d Mon Sep 17 00:00:00 2001 From: ryannewington Date: Thu, 21 Jul 2016 17:54:48 +1000 Subject: [PATCH] Adds workaround for sync engine lock ups by processing FIM MA DIs in the sync step queue Fixes an issue where a run profile may be added to a queue multiple times --- .../Product.wxs | 2 +- .../EventArgs/ExecutionParameters.cs | 23 ++++++++++++++----- src/Lithnet.Miiserver.AutoSync/MAExecutor.cs | 20 +++++++++++++++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/Lithnet.Miiserver.AutoSync.Setup/Product.wxs b/src/Lithnet.Miiserver.AutoSync.Setup/Product.wxs index f3da863..9fcf631 100644 --- a/src/Lithnet.Miiserver.AutoSync.Setup/Product.wxs +++ b/src/Lithnet.Miiserver.AutoSync.Setup/Product.wxs @@ -4,7 +4,7 @@ diff --git a/src/Lithnet.Miiserver.AutoSync/EventArgs/ExecutionParameters.cs b/src/Lithnet.Miiserver.AutoSync/EventArgs/ExecutionParameters.cs index ffdd242..33d1938 100644 --- a/src/Lithnet.Miiserver.AutoSync/EventArgs/ExecutionParameters.cs +++ b/src/Lithnet.Miiserver.AutoSync/EventArgs/ExecutionParameters.cs @@ -4,7 +4,7 @@ namespace Lithnet.Miiserver.AutoSync { public class ExecutionParameters { - public bool Exclusive { get; set; } + public bool Exclusive { get; set; } public string RunProfileName { get; set; } @@ -25,13 +25,13 @@ public ExecutionParameters(MARunProfileType runProfileType) } public ExecutionParameters(string runProfileName, bool exclusive) - :this(runProfileName) + : this(runProfileName) { this.Exclusive = exclusive; } public ExecutionParameters(MARunProfileType runProfileType, bool exclusive) - :this(runProfileType) + : this(runProfileType) { this.Exclusive = exclusive; } @@ -45,9 +45,20 @@ public override bool Equals(object obj) return object.ReferenceEquals(this, obj); } - return (string.Equals(this.RunProfileName, p2.RunProfileName, StringComparison.OrdinalIgnoreCase) && - this.RunProfileType == p2.RunProfileType && - this.Exclusive == p2.Exclusive); + if (!string.IsNullOrWhiteSpace(this.RunProfileName)) + { + if (string.Equals(this.RunProfileName, p2.RunProfileName, StringComparison.OrdinalIgnoreCase) && this.Exclusive == p2.Exclusive) + { + return true; + } + } + + if (this.RunProfileType == p2.RunProfileType && this.Exclusive == p2.Exclusive) + { + return true; + } + + return false; } public override int GetHashCode() diff --git a/src/Lithnet.Miiserver.AutoSync/MAExecutor.cs b/src/Lithnet.Miiserver.AutoSync/MAExecutor.cs index cccc291..37e8a18 100644 --- a/src/Lithnet.Miiserver.AutoSync/MAExecutor.cs +++ b/src/Lithnet.Miiserver.AutoSync/MAExecutor.cs @@ -554,7 +554,7 @@ private void Init() { this.ExecutingRunProfile = action.RunProfileName; - if (this.ma.RunProfiles[action.RunProfileName].RunSteps.Any(t => t.IsSyncStep)) + if (this.IsSyncStepOrFIMMADeltaImport(action.RunProfileName)) { lock (MAExecutor.GlobalSynchronizationStepLock) { @@ -577,6 +577,24 @@ private void Init() } } + private bool IsSyncStepOrFIMMADeltaImport(string runProfileName) + { + if (this.ma.RunProfiles[runProfileName].RunSteps.Any(t => t.IsSyncStep)) + { + return true; + } + + if (this.ma.Category == "FIM") + { + if (this.ma.RunProfiles[runProfileName].RunSteps.Any(t => t.Type == RunStepType.DeltaImport)) + { + return true; + } + } + + return false; + } + private void CheckAndQueueUnmanagedChanges() { this.localOperationLock.WaitOne();