2009-01-07 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Thu, 8 Jan 2009 02:17:59 +0000 (02:17 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Thu, 8 Jan 2009 02:17:59 +0000 (02:17 -0000)
* icall.c: Wrap calls to mono_strtod in CriticalSection
invocations when using eglib, to work around #464316.

svn path=/trunk/mono/; revision=122734

mono/metadata/ChangeLog
mono/metadata/icall.c

index f29b4818c1adb9a89362a7e2a80f5c57a92e5a35..3df46077af62d0fcc7c75d555279852e5a5c2649 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-07  Miguel de Icaza  <miguel@novell.com>
+
+       * icall.c: Wrap calls to mono_strtod in CriticalSection
+       invocations when using eglib, to work around #464316.
+
 2009-01-07 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * file-io.c (ves_icall_System_IO_MonoIO_GetCurrentDirectory): Double check the
index 687f33243cffced14a6612c3fd6914407337d079..6c647552b4bced83f4e3d0a9c5fa730ee4283b9f 100644 (file)
@@ -86,6 +86,12 @@ is_generic_parameter (MonoType *type)
        return !type->byref && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR);
 }
 
+#ifdef _EGLIB_MAJOR
+/* Need to lock here because EGLIB has locking defined as no-ops, we can not depend on mono_strtod do the right locking */
+/* Ideally this will be fixed in eglib */
+static CRITICAL_SECTION loader_mutex;
+#endif
+
 /*
  * We expect a pointer to a char, not a string
  */
@@ -101,8 +107,16 @@ mono_double_ParseImpl (char *ptr, double *result)
        if (*ptr)
                *result = strtod (ptr, &endptr);
 #else
-       if (*ptr)
+       if (*ptr){
+#ifdef _EGLIB_MAJOR
+               /* Need to lock here because EGLIB has locking defined as no-ops, and that breaks mono_strtod */
+               EnterCriticalSection (&strtod_mutex);
                *result = mono_strtod (ptr, &endptr);
+               LeaveCriticalSection (&strtod_mutex);
+#else
+               *result = mono_strtod (ptr, &endptr);
+#endif
+       }
 #endif
 
        if (!*ptr || (endptr && *endptr))