* DiagnosticsConfigurationHandler.cs: Make DiagnosticsConfiguration.Settings
authorJonathan Pryor <jpryor@novell.com>
Thu, 13 Jan 2005 22:00:27 +0000 (22:00 -0000)
committerJonathan Pryor <jpryor@novell.com>
Thu, 13 Jan 2005 22:00:27 +0000 (22:00 -0000)
    thread-safe (double-checked locking isn't thread safe on .NET without
    using a volatile variable, and setting the variable in the static
    constructor is easier anyway).
  * Switch.cs (GetConfigFileSetting): If the setting is non-numeric, set the
    attribute value to the string "0".  This is apparently what .NET 1.1 does,
    and allows the SwitchTest NUnit test to work w/o failures.

svn path=/trunk/mcs/; revision=38902

mcs/class/System/System.Diagnostics/ChangeLog
mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs
mcs/class/System/System.Diagnostics/Switch.cs

index 8da2855cd6e7c7c1831ed9a52807746c189fb8d3..578b0d22d536b6667478e90288da2b58adface43 100644 (file)
@@ -1,3 +1,13 @@
+2005-01-13 Jonathan Pryor  <jonpryor@vt.edu>
+
+       * DiagnosticsConfigurationHandler.cs: Make DiagnosticsConfiguration.Settings
+         thread-safe (double-checked locking isn't thread safe on .NET without
+         using a volatile variable, and setting the variable in the static
+         constructor is easier anyway).
+       * Switch.cs (GetConfigFileSetting): If the setting is non-numeric, set the
+         attribute value to the string "0".  This is apparently what .NET 1.1 does,
+         and allows the SwitchTest NUnit test to work w/o failures.
+
 2004-12-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Process.cs: always pass the same arguments to the runtime.
index 8821e14e1de9247f818930d11b72597d7adfd050..7c5c10c8d20ed9fbcc606cbb368e063b9a5ab4d2 100644 (file)
@@ -8,7 +8,7 @@
 //     John R. Hicks <angryjohn69@nc.rr.com>
 //     Jonathan Pryor <jonpryor@vt.edu>
 //
-// (C) 2002
+// (C) 2002, 2005
 //
 
 //
@@ -41,19 +41,11 @@ namespace System.Diagnostics
 {
        internal sealed class DiagnosticsConfiguration
        {
-               private static IDictionary settings = null;
+               private static IDictionary settings = 
+                       (IDictionary) ConfigurationSettings.GetConfig ("system.diagnostics");
 
                public static IDictionary Settings {
                        get {
-                               // TODO: Does anybody know if this is actually thread-safe under .NET?
-                               // I've heard that this construct isn't safe under Java, but it's used
-                               // reasonably often under C++, so I'm not sure about .NET.
-                               if (settings == null) {
-                                       lock (typeof(DiagnosticsConfiguration)) {
-                                               if (settings == null)
-                                                       settings = (IDictionary) ConfigurationSettings.GetConfig ("system.diagnostics");
-                                       }
-                               }
                                return settings;
                        }
                }
index 52fc1015ca440ad728f758ba5e79ebe5338baa3e..10de333a942fc094e5e4c9c7d359c40907a6321c 100755 (executable)
@@ -91,14 +91,16 @@ namespace System.Diagnostics
 
                private void GetConfigFileSetting ()
                {
+                       IDictionary d = (IDictionary) DiagnosticsConfiguration.Settings ["switches"];
                        try {
                                
                                // Load up the specified switch
-                               IDictionary d = (IDictionary) DiagnosticsConfiguration.Settings ["switches"];
                                if (d != null)
                                        switchSetting = int.Parse (d [name].ToString());
                        } catch {
                                switchSetting = 0;
+                               if (d != null)
+                                       d [name] = "0";
                        }
                }