Small cleanup on runtime shutdown to move more code to the same spot and reduce dupli...
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 12 Mar 2013 21:43:57 +0000 (17:43 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 12 Mar 2013 21:43:57 +0000 (17:43 -0400)
mono/metadata/icall.c
mono/metadata/runtime.c
mono/metadata/threads.c
mono/mini/debugger-agent.c

index ed34f324fc96e03b17aa06a093c71102e58b846a..34e206b11e73afef69665e045818ffb5c72e72be 100644 (file)
@@ -6530,13 +6530,7 @@ ves_icall_System_Environment_Exit (int result)
 {
        MONO_ARCH_SAVE_REGS;
 
-#ifndef MONO_CROSS_COMPILE
        mono_runtime_shutdown ();
-#endif
-
-       mono_threads_set_shutting_down ();
-
-       mono_runtime_set_shutting_down ();
 
        /* This will kill the tp threads which cannot be suspended */
        mono_thread_pool_cleanup ();
index 276a519f0d3d7d8b5b9bcd52dd0057367ebdf1f4..ed32066b8dc1e1f2e6493efa075786db69799c5d 100644 (file)
@@ -16,6 +16,7 @@
 #include <mono/metadata/class-internals.h>
 #include <mono/metadata/runtime.h>
 #include <mono/metadata/monitor.h>
+#include <mono/metadata/threads-types.h>
 
 static void
 fire_process_exit_event (MonoDomain *domain, gpointer user_data)
@@ -36,10 +37,30 @@ fire_process_exit_event (MonoDomain *domain, gpointer user_data)
        mono_runtime_delegate_invoke (delegate, pa, &exc);
 }
 
+static void
+mono_runtime_fire_process_exit_event (void)
+{
+#ifndef MONO_CROSS_COMPILE
+       mono_domain_foreach (fire_process_exit_event, NULL);
+#endif
+}
+
+/*
+Initialize runtime shutdown.
+After this call completes the thread pool will stop accepting new jobs and
+
+*/
 void
 mono_runtime_shutdown (void)
 {
-       mono_domain_foreach (fire_process_exit_event, NULL);
+       mono_runtime_fire_process_exit_event ();
+
+       mono_threads_set_shutting_down ();
+
+       /* No new threads will be created after this point */
+
+       mono_runtime_set_shutting_down ();
+
 }
 
 
index 56a1ea2646be71194ebe78c192d034ce8c60dd2f..33c01926d95c8659e0227531511f5d43406a0bc8 100644 (file)
@@ -2907,15 +2907,7 @@ void mono_thread_manage (void)
                THREAD_DEBUG (g_message ("%s: I have %d threads after waiting.", __func__, wait->num));
        } while(wait->num>0);
 
-#ifndef MONO_CROSS_COMPILE
        mono_runtime_shutdown ();
-#endif
-
-       mono_threads_set_shutting_down ();
-
-       /* No new threads will be created after this point */
-
-       mono_runtime_set_shutting_down ();
 
        THREAD_DEBUG (g_message ("%s: threadpool cleanup", __func__));
        mono_thread_pool_cleanup ();
index b12019e273fc96993c81075e15fc59fb32ee79e2..3bb26c41513f91f876c87eeae805b13978be3413 100644 (file)
@@ -72,6 +72,7 @@ int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
 #include <mono/metadata/threads-types.h>
 #include <mono/metadata/socket-io.h>
 #include <mono/metadata/assembly.h>
+#include <mono/metadata/runtime.h>
 #include <mono/utils/mono-semaphore.h>
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/mono-stack-unwinding.h>
@@ -6438,9 +6439,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf)
                        while (suspend_count > 0)
                                resume_vm ();
 
-                       mono_runtime_set_shutting_down ();
-
-                       mono_threads_set_shutting_down ();
+                       mono_runtime_shutdown ();
 
                        /* Suspend all managed threads since the runtime is going away */
                        DEBUG(1, fprintf (log_file, "Suspending all threads...\n"));