2003-10-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 9 Oct 2003 20:34:50 +0000 (20:34 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 9 Oct 2003 20:34:50 +0000 (20:34 -0000)
* MonoCustomAttrs.cs: from_cache is now thread-safe. Yeah, I got a
duplicate entry exception.

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

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/MonoCustomAttrs.cs

index b60a6b5e3e93b66b859cf3da348477086669b738..2e12b09ca41ec6c53c726554e9df1ec7211d9fdd 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-09  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * MonoCustomAttrs.cs: from_cache is now thread-safe. Yeah, I got a
+       duplicate entry exception.
+
 2003-10-08 Ben Maurer  <bmaurer@users.sourceforge.net>
 
        * DateTime.cs (ToString): Total rewrite, fixes #49358.
index 4f338eda78dd3461bcf4cbf8ceab9990589db1a1..bd841ee3812a823e6681758126f9c4155563a237 100755 (executable)
@@ -23,12 +23,14 @@ namespace System {
 
                private static object[] from_cache (ICustomAttributeProvider obj)
                {
-                       object[] res = (object []) handle_to_attrs [obj];
-                       if (res != null)
+                       lock (handle_to_attrs) {
+                               object[] res = (object []) handle_to_attrs [obj];
+                               if (res != null)
+                                       return res;
+                               res = GetCustomAttributes (obj);
+                               handle_to_attrs.Add (obj, res);
                                return res;
-                       res = GetCustomAttributes (obj);
-                       handle_to_attrs.Add (obj, res);
-                       return res;
+                       }
                }
 
                internal static Attribute GetCustomAttribute (ICustomAttributeProvider obj,
@@ -82,7 +84,7 @@ namespace System {
                                return r;
                        }
 
-                       ArrayList a = new ArrayList ();
+                       ArrayList a = new ArrayList (res.Length < 16 ? res.Length : 16);
                        ICustomAttributeProvider btype = obj;
                        do {
                                foreach (object attr in res)