X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-threads.c;h=e26ca1760c6fb49214c735925a064146b8005ec7;hb=9df453295e5f5f733aa1edf445f9acaf2354e8b7;hp=c7b4ae76384c6dc7ae7560ba8074a22f22aa09fa;hpb=310be7a2fbfdaf008d9525b9c2771b3fc1205f0b;p=mono.git diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c index c7b4ae76384..e26ca1760c6 100644 --- a/mono/utils/mono-threads.c +++ b/mono/utils/mono-threads.c @@ -965,7 +965,7 @@ suspend_sync (MonoNativeThreadId tid, gboolean interrupt_kernel) if (interrupt_kernel) mono_threads_suspend_abort_syscall (info); - break; + return info; default: g_assert_not_reached (); } @@ -1086,27 +1086,35 @@ STW to make sure no unsafe pending suspend is in progress. static void mono_thread_info_suspend_lock_with_info (MonoThreadInfo *info) { - if (mono_threads_is_coop_enabled ()) { - g_assert (info); - g_assert (mono_thread_info_is_current (info)); - g_assert (mono_thread_info_is_live (info)); + g_assert (info); + g_assert (mono_thread_info_is_current (info)); + g_assert (mono_thread_info_is_live (info)); - MONO_ENTER_GC_SAFE_WITH_INFO(info); + MONO_ENTER_GC_SAFE_WITH_INFO(info); - int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE); - g_assert (res != -1); + int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE); + g_assert (res != -1); - MONO_EXIT_GC_SAFE_WITH_INFO; - } else { - int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE); - g_assert (res != -1); - } + MONO_EXIT_GC_SAFE_WITH_INFO; } void mono_thread_info_suspend_lock (void) { - mono_thread_info_suspend_lock_with_info (mono_thread_info_current_unchecked ()); + MonoThreadInfo *info; + gint res; + + info = mono_thread_info_current_unchecked (); + if (info && mono_thread_info_is_live (info)) { + mono_thread_info_suspend_lock_with_info (info); + return; + } + + /* mono_thread_info_suspend_lock () can be called from boehm-gc.c on_gc_notification before the new thread's + * start_wrapper calls mono_thread_info_attach but after pthread_create calls the start wrapper. */ + + res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE); + g_assert (res != -1); } void