From 4f4cb919cf796437bb4be05df4dac5cd2f4e6ee5 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 7 Feb 2017 15:13:12 -0500 Subject: [PATCH] [threadpool] Fix hang on threadpool cleanup (#4331) Waiting for the threadpool threads to exit on shutdown triggers a hand. The simplest solution is to not wait for them, and let the general runtime shutdown mechanism wait for them (see `mono_thread_manage`). --- mono/metadata/threadpool-worker-default.c | 2 ++ mono/metadata/threadpool.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mono/metadata/threadpool-worker-default.c b/mono/metadata/threadpool-worker-default.c index e882574ab15..6c499ebac9b 100644 --- a/mono/metadata/threadpool-worker-default.c +++ b/mono/metadata/threadpool-worker-default.c @@ -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); diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index dfd61ea3f58..e58a78d47e0 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -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); -- 2.11.4.GIT