Skip to content

Commit 595171b

Browse files
committed
Added flag to see if the configuration is currently updating
Config header checks can force an update as well as the settings timer running on the client at the same time. One problem with this is that SettingsManager is stateless and could have mutliple clients using it. This change can prevent multiple clients from updating at the same time. There are already checks in the client instance but they are not visible to the submission client
1 parent 373888b commit 595171b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Exceptionless/Configuration/SettingsManager.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace Exceptionless.Configuration {
1010
public static class SettingsManager {
11+
private static bool _isUpdatingSettings = false;
12+
1113
public static void ApplySavedServerSettings(ExceptionlessConfiguration config) {
1214
if (config == null)
1315
return;
@@ -33,7 +35,7 @@ private static SettingsDictionary GetSavedServerSettings(ExceptionlessConfigurat
3335
var fileStorage = config.Resolver.GetFileStorage();
3436
if (!fileStorage.Exists(configPath))
3537
return new SettingsDictionary();
36-
38+
3739
return fileStorage.GetObject<SettingsDictionary>(configPath);
3840
} catch (Exception ex) {
3941
config.Resolver.GetLog().FormattedError(typeof(SettingsManager), ex, "Unable to read and apply saved server settings: {0}", ex.Message);
@@ -69,10 +71,11 @@ public static void CheckVersion(int version, ExceptionlessConfiguration config)
6971
}
7072

7173
public static void UpdateSettings(ExceptionlessConfiguration config, int? version = null) {
72-
if (config == null || !config.IsValid || !config.Enabled)
74+
if (config == null || !config.IsValid || !config.Enabled || _isUpdatingSettings)
7375
return;
7476

7577
try {
78+
_isUpdatingSettings = true;
7679
if (!version.HasValue || version < 0)
7780
version = GetVersion(config);
7881

@@ -98,6 +101,8 @@ public static void UpdateSettings(ExceptionlessConfiguration config, int? versio
98101
fileStorage.SaveObject(GetConfigPath(config), response.Settings);
99102
} catch (Exception ex) {
100103
config.Resolver.GetLog().Error(typeof(SettingsManager), ex, "Error occurred updating settings.");
104+
} finally {
105+
_isUpdatingSettings = false;
101106
}
102107
}
103108

0 commit comments

Comments
 (0)