[threadpool] Fix hang on threadpool cleanup (#4330)
[mono.git] / mono / metadata / threadpool.c
index 75de23a393c84f22bcd12730204933c9b73458d6..e58a78d47e0e37e9669762067b68316268d9caf5 100644 (file)
@@ -45,7 +45,6 @@
 #include <mono/utils/mono-threads.h>
 #include <mono/utils/mono-time.h>
 #include <mono/utils/refcount.h>
-#include <mono/io-layer/io-layer.h>
 
 typedef struct {
        MonoDomain *domain;
@@ -188,6 +187,7 @@ cleanup (void)
 
        mono_coop_mutex_unlock (&threadpool->threads_lock);
 
+#if 0
        /* give a chance to the other threads to exit */
        mono_thread_info_yield ();
 
@@ -206,6 +206,7 @@ cleanup (void)
        }
 
        mono_coop_mutex_unlock (&threadpool->threads_lock);
+#endif
 
        mono_threadpool_worker_cleanup (threadpool->worker);
 
@@ -567,7 +568,7 @@ mono_threadpool_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, MonoObj
                        g_assert(wait_event);
                        MonoWaitHandle *wait_handle = mono_wait_handle_new (mono_object_domain (ares), wait_event, error);
                        if (!is_ok (error)) {
-                               CloseHandle (wait_event);
+                               mono_w32event_close (wait_event);
                                return NULL;
                        }
                        MONO_OBJECT_SETREF (ares, handle, (MonoObject*) wait_handle);