From ede498bb6fc08d45c8eaeafb2be08ea3c8e1066a Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 7 Feb 2017 15:09:47 -0500 Subject: [PATCH] [threadpool] Fix hang on threadpool cleanup (#4330) 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 | 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.25.1