X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fthreads.c;h=3921c7e352205fb6d5e6ec98707f916181118e57;hb=03cf658591fa6238963f7861d16f9c9a95b3817b;hp=fdb6934036b3eadbe8c1263642f9d70083ef205d;hpb=3e6a602dd1529685ef4ba64a384d7e6b2edc8f09;p=mono.git diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index fdb6934036b..3921c7e3522 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -2933,34 +2933,14 @@ wait_for_tids (struct wait_data *wait, guint32 timeout) return; for(i=0; inum; i++) { - gsize tid = wait->threads[i]->tid; + MonoInternalThread *internal; - /* - * On !win32, when the thread handle becomes signalled, it just means the thread has exited user code, - * it can still run io-layer etc. code. So wait for it to really exit. - * FIXME: This won't join threads which are not in the joinable_hash yet. - */ - mono_thread_join ((gpointer)tid); + internal = wait->threads [i]; mono_threads_lock (); - if(mono_g_hash_table_lookup (threads, (gpointer)tid)!=NULL) { - /* This thread must have been killed, because - * it hasn't cleaned itself up. (It's just - * possible that the thread exited before the - * parent thread had a chance to store the - * handle, and now there is another pointer to - * the already-exited thread stored. In this - * case, we'll just get two - * mono_profiler_thread_end() calls for the - * same thread.) - */ - - mono_threads_unlock (); - THREAD_DEBUG (g_message ("%s: cleaning up after thread %p (%"G_GSIZE_FORMAT")", __func__, wait->threads[i], tid)); - thread_cleanup (wait->threads[i]); - } else { - mono_threads_unlock (); - } + if (mono_g_hash_table_lookup (threads, (gpointer) internal->tid) == internal) + g_error ("%s: failed to call mono_thread_detach_internal on thread %p, InternalThread: %p", __func__, internal->tid, internal); + mono_threads_unlock (); } } @@ -2996,15 +2976,14 @@ static void wait_for_tids_or_state_change (struct wait_data *wait, guint32 timeo return; if (ret < wait->num) { - gsize tid = wait->threads[ret]->tid; + MonoInternalThread *internal; + + internal = wait->threads [ret]; + mono_threads_lock (); - if (mono_g_hash_table_lookup (threads, (gpointer)tid)!=NULL) { - /* See comment in wait_for_tids about thread cleanup */ - mono_threads_unlock (); - THREAD_DEBUG (g_message ("%s: cleaning up after thread %"G_GSIZE_FORMAT, __func__, tid)); - thread_cleanup (wait->threads [ret]); - } else - mono_threads_unlock (); + if (mono_g_hash_table_lookup (threads, (gpointer) internal->tid) == internal) + g_error ("%s: failed to call mono_thread_detach_internal on thread %p, InternalThread: %p", __func__, internal->tid, internal); + mono_threads_unlock (); } }