diff options
author | AlexGhiondea <AlexGhiondea@users.noreply.github.com> | 2016-01-19 21:04:13 -0800 |
---|---|---|
committer | AlexGhiondea <AlexGhiondea@users.noreply.github.com> | 2016-01-19 21:04:13 -0800 |
commit | b8a59ae34861b8b4b0dddc224a1c5eef15674a70 (patch) | |
tree | 52479853cb501a62ae7206efb82df631eb7e41cb /src/mscorlib | |
parent | 76f9db8e1977a98f753d4bb474aa3f392e5daaec (diff) | |
parent | 5845a94d9e1b27f294e2d183414244bfecb02d47 (diff) | |
download | coreclr-b8a59ae34861b8b4b0dddc224a1c5eef15674a70.tar.gz coreclr-b8a59ae34861b8b4b0dddc224a1c5eef15674a70.tar.bz2 coreclr-b8a59ae34861b8b4b0dddc224a1c5eef15674a70.zip |
Merge pull request #2729 from JonHanna/fix_2727
Ensure same lock is used to read and write Dictionary in AppContext
Diffstat (limited to 'src/mscorlib')
-rw-r--r-- | src/mscorlib/src/System/AppContext/AppContext.cs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mscorlib/src/System/AppContext/AppContext.cs b/src/mscorlib/src/System/AppContext/AppContext.cs index 30a405d7c9..ecd85d3dbe 100644 --- a/src/mscorlib/src/System/AppContext/AppContext.cs +++ b/src/mscorlib/src/System/AppContext/AppContext.cs @@ -16,8 +16,7 @@ namespace System HasLookedForOverride = 0x4, UnknownValue = 0x8 // Has no default and could not find an override } - private static Dictionary<string, SwitchValueState> s_switchMap = new Dictionary<string, SwitchValueState>(); - private static readonly object s_syncLock = new object(); + private static readonly Dictionary<string, SwitchValueState> s_switchMap = new Dictionary<string, SwitchValueState>(); public static string BaseDirectory { @@ -157,11 +156,13 @@ namespace System if (switchName.Length == 0) throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "switchName"); - lock (s_syncLock) + SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue) + | SwitchValueState.HasLookedForOverride; + + lock (s_switchMap) { // Store the new value and the fact that we checked in the dictionary - s_switchMap[switchName] = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue) - | SwitchValueState.HasLookedForOverride; + s_switchMap[switchName] = switchValue; } } |