[threadpool] Fix hang on threadpool cleanup (#4330)
authorLudovic Henry <ludovic@xamarin.com>
Tue, 7 Feb 2017 20:09:47 +0000 (15:09 -0500)
committerGitHub <noreply@github.com>
Tue, 7 Feb 2017 20:09:47 +0000 (15:09 -0500)
Waiting for the threadpool threads to exit on shutdown triggers a hand. The simplest solution is to not wait for them, and let the OS clean them up.

This is not an ideal solution, but this is to fix a months-long chase for this bug, and to release a less-buggy monthly release.

mono/metadata/threadpool-worker-default.c
mono/metadata/threadpool.c

index e882574ab15b10b5dbf188256f7e6c015094c421..6c499ebac9b2f9bead737848bf52ded8420036b6 100644 (file)
@@ -333,6 +333,7 @@ mono_threadpool_worker_cleanup (MonoThreadPoolWorker *worker)
        /* unpark all worker->parked_threads */
        mono_coop_cond_broadcast (&worker->parked_threads_cond);
 
+#if 0
        for (;;) {
                ThreadPoolWorkerCounter counter;
 
@@ -349,6 +350,7 @@ mono_threadpool_worker_cleanup (MonoThreadPoolWorker *worker)
 
                mono_coop_cond_wait (&worker->threads_exit_cond, &worker->threads_lock);
        }
+#endif
 
        mono_coop_mutex_unlock (&worker->threads_lock);
 
index dfd61ea3f589177a1aa7c7f9cd877e85488a6052..e58a78d47e0e37e9669762067b68316268d9caf5 100644 (file)
@@ -187,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 ();
 
@@ -205,6 +206,7 @@ cleanup (void)
        }
 
        mono_coop_mutex_unlock (&threadpool->threads_lock);
+#endif
 
        mono_threadpool_worker_cleanup (threadpool->worker);