2004-07-15 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Thu, 15 Jul 2004 14:28:40 +0000 (14:28 -0000)
committerDick Porter <dick@acm.org>
Thu, 15 Jul 2004 14:28:40 +0000 (14:28 -0000)
* Thread.cs: Hold a lock in GetNamedDataSlot.  Fixes bug 61582,
based on patch by S�bastien Robitaille
(sebastien.robitaille@croesus.com).  Also fix instances of
lock(typeof(Thread)) to lock a private object instead.

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

mcs/class/corlib/System.Threading/ChangeLog
mcs/class/corlib/System.Threading/Thread.cs

index 7f2c3f55e2d9f5dc78dcdd4ac9dae449e478610b..ab85c67acf785ad7dd7ddb16130e9cd44a2fca72 100644 (file)
@@ -1,3 +1,10 @@
+2004-07-15  Dick Porter  <dick@ximian.com>
+
+       * Thread.cs: Hold a lock in GetNamedDataSlot.  Fixes bug 61582,
+       based on patch by Sébastien Robitaille
+       (sebastien.robitaille@croesus.com).  Also fix instances of
+       lock(typeof(Thread)) to lock a private object instead.
+
 2004-07-14  Sebastien Pouliot  <sebastien@ximian.com>
 
        * AsyncFlowControl.cs: New structure in Fx 2.0 required in 
index 66826e12d409edde4a833a034f7b6135d82ef672..949760b1a225c9033c6a306eea01898f663bad32 100755 (executable)
@@ -157,9 +157,10 @@ namespace System.Threading
 
                // Stores a hash keyed by strings of LocalDataStoreSlot objects
                static Hashtable datastorehash;
-
+               private static object datastore_lock = new object ();
+               
                private static void InitDataStoreHash () {
-                       lock (typeof (Thread)) {
+                       lock (datastore_lock) {
                                if (datastorehash == null) {
                                        datastorehash = Hashtable.Synchronized(new Hashtable());
                                }
@@ -167,7 +168,7 @@ namespace System.Threading
                }
                
                public static LocalDataStoreSlot AllocateNamedDataSlot(string name) {
-                       lock (typeof (Thread)) {
+                       lock (datastore_lock) {
                                if (datastorehash == null)
                                        InitDataStoreHash ();
                                LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash[name];
@@ -186,7 +187,7 @@ namespace System.Threading
                }
 
                public static void FreeNamedDataSlot(string name) {
-                       lock (typeof (Thread)) {
+                       lock (datastore_lock) {
                                if (datastorehash == null)
                                        InitDataStoreHash ();
                                LocalDataStoreSlot slot=(LocalDataStoreSlot)datastorehash[name];
@@ -210,15 +211,17 @@ namespace System.Threading
                public extern static int GetDomainID();
 
                public static LocalDataStoreSlot GetNamedDataSlot(string name) {
-                       if (datastorehash == null)
-                               InitDataStoreHash ();
-                       LocalDataStoreSlot slot=(LocalDataStoreSlot)datastorehash[name];
+                       lock (datastore_lock) {
+                               if (datastorehash == null)
+                                       InitDataStoreHash ();
+                               LocalDataStoreSlot slot=(LocalDataStoreSlot)datastorehash[name];
 
-                       if(slot==null) {
-                               slot=AllocateNamedDataSlot(name);
-                       }
+                               if(slot==null) {
+                                       slot=AllocateNamedDataSlot(name);
+                               }
                        
-                       return(slot);
+                               return(slot);
+                       }
                }
                
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -299,7 +302,7 @@ namespace System.Threading
                public CultureInfo CurrentCulture {
                        get {
                                if (current_culture == null) {
-                                       lock (typeof (Thread)) {
+                                       lock (synch_lock) {
                                                if(current_culture==null) {
                                                        if(in_currentculture==true) {
                                                                /* Bail out */