Merge pull request #3211 from BrzVlad/fix-finalizer-thread-exited
authorVlad Brezae <brezaevlad@gmail.com>
Fri, 1 Jul 2016 20:56:31 +0000 (23:56 +0300)
committerGitHub <noreply@github.com>
Fri, 1 Jul 2016 20:56:31 +0000 (23:56 +0300)
[sgen] Speed up domain finalization at shutdown

mono/metadata/gc.c

index e44f07f6d8329cb3e3811eb9387baeb4aa6654a0..3b116d8322fbc74a66f7c1a628d93bca56fac232 100644 (file)
@@ -105,7 +105,7 @@ add_thread_to_finalize (MonoInternalThread *thread, MonoError *error)
        return is_ok (error);
 }
 
-static gboolean suspend_finalizers = FALSE;
+static volatile gboolean suspend_finalizers = FALSE;
 /* 
  * actually, we might want to queue the finalize requests in a separate thread,
  * but we need to be careful about the execution domain of the thread...
@@ -724,7 +724,7 @@ finalize_domain_objects (DomainFinalizationReq *req)
                g_ptr_array_free (objs, TRUE);
        }
 #elif defined(HAVE_SGEN_GC)
-       while ((count = mono_gc_finalizers_for_domain (domain, to_finalize, NUM_FOBJECTS))) {
+       while (!suspend_finalizers && (count = mono_gc_finalizers_for_domain (domain, to_finalize, NUM_FOBJECTS))) {
                int i;
                for (i = 0; i < count; ++i) {
                        mono_gc_run_finalize (to_finalize [i], 0);