Merge pull request #4621 from alexanderkyte/strdup_env
[mono.git] / mono / utils / mono-threads-coop.c
index 7f2748536830157d0179423a510f6c7e21e9b6da..0d5f1e9b73577e3ce129005e5dedf4de73dc3972 100644 (file)
@@ -1,5 +1,6 @@
- /*
- * mono-threads.c: Coop threading
+/**
+ * \file
+ * Coop threading
  *
  * Author:
  *     Rodrigo Kumpera (kumpera@gmail.com)
@@ -288,6 +289,12 @@ mono_threads_exit_gc_safe_region_unbalanced (gpointer cookie, gpointer *stackdat
        default:
                g_error ("Unknown thread state");
        }
+
+       if (info->async_target) {
+               info->async_target (info->user_data);
+               info->async_target = NULL;
+               info->user_data = NULL;
+       }
 }
 
 void
@@ -355,6 +362,12 @@ mono_threads_enter_gc_unsafe_region_unbalanced_with_info (MonoThreadInfo *info,
                g_error ("Unknown thread state");
        }
 
+       if (info->async_target) {
+               info->async_target (info->user_data);
+               info->async_target = NULL;
+               info->user_data = NULL;
+       }
+
        return info;
 }
 
@@ -417,7 +430,7 @@ mono_threads_is_coop_enabled (void)
 #else
        static int is_coop_enabled = -1;
        if (G_UNLIKELY (is_coop_enabled == -1))
-               is_coop_enabled = g_getenv ("MONO_ENABLE_COOP") != NULL ? 1 : 0;
+               is_coop_enabled = g_hasenv ("MONO_ENABLE_COOP") ? 1 : 0;
        return is_coop_enabled == 1;
 #endif
 }