Author: dick
Date: 2008-01-23 10:56:43 -0500 (Wed, 23 Jan 2008)
New Revision: 93664
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/icall.c
trunk/mono/mono/metadata/threads-types.h
trunk/mono/mono/metadata/threads.c
Log:
2008-01-23 Dick Porter <[EMAIL PROTECTED]>
* threads.c (mono_threads_set_shutting_down): Simplify shutdown
procedure, and make it work on windows.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2008-01-23 15:46:32 UTC (rev 93663)
+++ trunk/mono/mono/metadata/ChangeLog 2008-01-23 15:56:43 UTC (rev 93664)
@@ -1,3 +1,8 @@
+2008-01-23 Dick Porter <[EMAIL PROTECTED]>
+
+ * threads.c (mono_threads_set_shutting_down): Simplify shutdown
+ procedure, and make it work on windows.
+
2008-01-22 Zoltan Varga <[EMAIL PROTECTED]>
* object-internals.h (MonoReflectionGenericClass): Make the
'generic_type' field
Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c 2008-01-23 15:46:32 UTC (rev 93663)
+++ trunk/mono/mono/metadata/icall.c 2008-01-23 15:56:43 UTC (rev 93664)
@@ -6184,7 +6184,7 @@
{
MONO_ARCH_SAVE_REGS;
- if (!mono_threads_set_shutting_down (TRUE))
+ if (!mono_threads_set_shutting_down ())
return;
mono_runtime_set_shutting_down ();
Modified: trunk/mono/mono/metadata/threads-types.h
===================================================================
--- trunk/mono/mono/metadata/threads-types.h 2008-01-23 15:46:32 UTC (rev
93663)
+++ trunk/mono/mono/metadata/threads-types.h 2008-01-23 15:56:43 UTC (rev
93664)
@@ -143,7 +143,7 @@
void mono_thread_init_apartment_state (void) MONO_INTERNAL;
void mono_thread_cleanup_apartment_state (void) MONO_INTERNAL;
-gboolean mono_threads_set_shutting_down (gboolean may_abort) MONO_INTERNAL;
+gboolean mono_threads_set_shutting_down (void) MONO_INTERNAL;
gboolean mono_threads_is_shutting_down (void) MONO_INTERNAL;
MonoException* mono_thread_get_undeniable_exception (void);
Modified: trunk/mono/mono/metadata/threads.c
===================================================================
--- trunk/mono/mono/metadata/threads.c 2008-01-23 15:46:32 UTC (rev 93663)
+++ trunk/mono/mono/metadata/threads.c 2008-01-23 15:56:43 UTC (rev 93664)
@@ -2502,69 +2502,48 @@
/**
* mono_threads_set_shutting_down:
- * @may_abort: Whether the function is allowed to abort the current
- * thread if it cannot shut down Mono.
*
* Is called by a thread that wants to shut down Mono. Returs whether
* the thread is allowed to do that. The reason for not allowing it
* is because another thread has already commenced shutdown.
*/
gboolean
-mono_threads_set_shutting_down (gboolean may_abort)
+mono_threads_set_shutting_down (void)
{
MonoThread *current_thread = mono_thread_current ();
mono_threads_lock ();
if (shutting_down) {
- if (may_abort) {
- ves_icall_System_Threading_Thread_Abort
(current_thread, NULL);
+ mono_threads_unlock ();
- return FALSE;
- } else {
- mono_threads_unlock ();
+ /* Make sure we're properly suspended/stopped */
- /* Make sure we're properly suspended/stopped */
+ EnterCriticalSection (current_thread->synch_cs);
- EnterCriticalSection (current_thread->synch_cs);
-
- if ((current_thread->state &
ThreadState_SuspendRequested) ||
- (current_thread->state &
ThreadState_AbortRequested) ||
- (current_thread->state &
ThreadState_StopRequested)) {
- LeaveCriticalSection (current_thread->synch_cs);
- mono_thread_execute_interruption
(current_thread);
- } else {
- current_thread->state |= ThreadState_Stopped;
- LeaveCriticalSection (current_thread->synch_cs);
- }
-
- /* Wake up other threads potentially waiting for us */
-
- /* FIXME: We have to do this on Win32 in some way, too
*/
-#if !defined(PLATFORM_WIN32)
- _wapi_thread_signal_self (0);
-#endif
-
- /* Wait for the end of the world */
-
- for (;;)
- Sleep (10000);
+ if ((current_thread->state & ThreadState_SuspendRequested) ||
+ (current_thread->state & ThreadState_AbortRequested) ||
+ (current_thread->state & ThreadState_StopRequested)) {
+ LeaveCriticalSection (current_thread->synch_cs);
+ mono_thread_execute_interruption (current_thread);
+ } else {
+ current_thread->state |= ThreadState_Stopped;
+ LeaveCriticalSection (current_thread->synch_cs);
}
+
+ /* Wake up other threads potentially waiting for us */
+ ExitThread (0);
} else {
shutting_down = TRUE;
+ /* Not really a background state change, but this will
+ * interrupt the main thread if it is waiting for all
+ * the other threads.
+ */
+ SetEvent (background_change_event);
+
mono_threads_unlock ();
- /* Even though our state hasn't changed we still wake
- up other threads. Actually we only care about the
- main thread, which might be waiting for us to
- finish. */
-
- /* FIXME: We have to do this on Win32 in some way, too */
-#if !defined(PLATFORM_WIN32)
- _wapi_thread_signal_self (0);
-#endif
-
return TRUE;
}
}
@@ -2620,7 +2599,7 @@
THREAD_DEBUG (g_message ("%s: I have %d threads after
waiting.", __func__, wait->num));
} while(wait->num>0);
- mono_threads_set_shutting_down (FALSE);
+ mono_threads_set_shutting_down ();
/* No new threads will be created after this point */
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches