+2007-11-15 Dick Porter <dick@ximian.com>
+
+ * threads.c (ves_icall_System_Threading_Thread_Join_internal):
+ When joining a thread, it's the thread that's calling Join that
+ gets WaitSleepJoin state not the target. Fixes the standalone
+ test case in bug 334740, and hopefully the whole bug too.
+
2007-11-15 Dick Porter <dick@ximian.com>
* process.c: Read file version info from the files pointed at by
gboolean ves_icall_System_Threading_Thread_Join_internal(MonoThread *this,
int ms, HANDLE thread)
{
+ MonoThread *cur_thread = mono_thread_current ();
gboolean ret;
MONO_ARCH_SAVE_REGS;
mono_raise_exception (mono_get_exception_thread_state ("Thread has not been started."));
return FALSE;
}
-
- this->state |= ThreadState_WaitSleepJoin;
LeaveCriticalSection (this->synch_cs);
}
THREAD_DEBUG (g_message ("%s: joining thread handle %p, %d ms", __func__, thread, ms));
+ mono_thread_set_state (cur_thread, ThreadState_WaitSleepJoin);
+
ret=WaitForSingleObjectEx (thread, ms, TRUE);
- mono_thread_clr_state (this, ThreadState_WaitSleepJoin);
+ mono_thread_clr_state (cur_thread, ThreadState_WaitSleepJoin);
if(ret==WAIT_OBJECT_0) {
THREAD_DEBUG (g_message ("%s: join successful", __func__));