From 804044e4bd344cf7ef687e5736eb9d237cc5d5a5 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 8 Feb 2017 14:32:00 -0500 Subject: [PATCH] [threadpool] Make sure we check if the runtime is shutting down in case of interruption --- mono/metadata/threadpool.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index 455d616a767..7f7c31f0631 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -309,11 +309,11 @@ static ThreadPoolDomain * tpdomain_get_next (ThreadPoolDomain *current) { ThreadPoolDomain *tpdomain = NULL; - guint len; + gint len; len = threadpool.domains->len; if (len > 0) { - guint i, current_idx = -1; + gint i, current_idx = -1; if (current) { for (i = 0; i < len; ++i) { if (current == g_ptr_array_index (threadpool.domains, i)) { @@ -321,7 +321,6 @@ tpdomain_get_next (ThreadPoolDomain *current) break; } } - g_assert (current_idx != (guint)-1); } for (i = current_idx + 1; i < len + current_idx + 1; ++i) { ThreadPoolDomain *tmp = (ThreadPoolDomain *)g_ptr_array_index (threadpool.domains, i % len); @@ -388,9 +387,12 @@ worker_callback (gpointer unused) while (!mono_runtime_is_shutting_down ()) { gboolean retire = FALSE; - if ((thread->state & (ThreadState_AbortRequested | ThreadState_SuspendRequested)) != 0) { + if (thread->state & (ThreadState_AbortRequested | ThreadState_SuspendRequested)) { domains_unlock (); - mono_thread_interruption_checkpoint (); + if (mono_thread_interruption_checkpoint ()) { + domains_lock (); + continue; + } domains_lock (); } -- 2.25.1