Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Small cleanup on runtime shutdown to move more code to the same spot …

…and reduce duplication.
  • Loading branch information...
commit 3dcc728b8c675da0289f63f7d3697c61bb01ddad 1 parent 4df4b7a
Rodrigo Kumpera kumpera authored
6 mono/metadata/icall.c
@@ -6530,13 +6530,7 @@ ves_icall_System_Environment_Exit (int result)
6530 6530 {
6531 6531 MONO_ARCH_SAVE_REGS;
6532 6532
6533   -#ifndef MONO_CROSS_COMPILE
6534 6533 mono_runtime_shutdown ();
6535   -#endif
6536   -
6537   - mono_threads_set_shutting_down ();
6538   -
6539   - mono_runtime_set_shutting_down ();
6540 6534
6541 6535 /* This will kill the tp threads which cannot be suspended */
6542 6536 mono_thread_pool_cleanup ();
23 mono/metadata/runtime.c
@@ -16,6 +16,7 @@
16 16 #include <mono/metadata/class-internals.h>
17 17 #include <mono/metadata/runtime.h>
18 18 #include <mono/metadata/monitor.h>
  19 +#include <mono/metadata/threads-types.h>
19 20
20 21 static void
21 22 fire_process_exit_event (MonoDomain *domain, gpointer user_data)
@@ -36,10 +37,30 @@ fire_process_exit_event (MonoDomain *domain, gpointer user_data)
36 37 mono_runtime_delegate_invoke (delegate, pa, &exc);
37 38 }
38 39
  40 +static void
  41 +mono_runtime_fire_process_exit_event (void)
  42 +{
  43 +#ifndef MONO_CROSS_COMPILE
  44 + mono_domain_foreach (fire_process_exit_event, NULL);
  45 +#endif
  46 +}
  47 +
  48 +/*
  49 +Initialize runtime shutdown.
  50 +After this call completes the thread pool will stop accepting new jobs and
  51 +
  52 +*/
39 53 void
40 54 mono_runtime_shutdown (void)
41 55 {
42   - mono_domain_foreach (fire_process_exit_event, NULL);
  56 + mono_runtime_fire_process_exit_event ();
  57 +
  58 + mono_threads_set_shutting_down ();
  59 +
  60 + /* No new threads will be created after this point */
  61 +
  62 + mono_runtime_set_shutting_down ();
  63 +
43 64 }
44 65
45 66
8 mono/metadata/threads.c
@@ -2907,15 +2907,7 @@ void mono_thread_manage (void)
2907 2907 THREAD_DEBUG (g_message ("%s: I have %d threads after waiting.", __func__, wait->num));
2908 2908 } while(wait->num>0);
2909 2909
2910   -#ifndef MONO_CROSS_COMPILE
2911 2910 mono_runtime_shutdown ();
2912   -#endif
2913   -
2914   - mono_threads_set_shutting_down ();
2915   -
2916   - /* No new threads will be created after this point */
2917   -
2918   - mono_runtime_set_shutting_down ();
2919 2911
2920 2912 THREAD_DEBUG (g_message ("%s: threadpool cleanup", __func__));
2921 2913 mono_thread_pool_cleanup ();
5 mono/mini/debugger-agent.c
@@ -72,6 +72,7 @@ int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
72 72 #include <mono/metadata/threads-types.h>
73 73 #include <mono/metadata/socket-io.h>
74 74 #include <mono/metadata/assembly.h>
  75 +#include <mono/metadata/runtime.h>
75 76 #include <mono/utils/mono-semaphore.h>
76 77 #include <mono/utils/mono-error-internals.h>
77 78 #include <mono/utils/mono-stack-unwinding.h>
@@ -6438,9 +6439,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf)
6438 6439 while (suspend_count > 0)
6439 6440 resume_vm ();
6440 6441
6441   - mono_runtime_set_shutting_down ();
6442   -
6443   - mono_threads_set_shutting_down ();
  6442 + mono_runtime_shutdown ();
6444 6443
6445 6444 /* Suspend all managed threads since the runtime is going away */
6446 6445 DEBUG(1, fprintf (log_file, "Suspending all threads...\n"));

0 comments on commit 3dcc728

Please sign in to comment.
Something went wrong with that request. Please try again.