2005-01-11 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Tue, 11 Jan 2005 21:00:14 +0000 (21:00 -0000)
committerZoltan Varga <vargaz@gmail.com>
Tue, 11 Jan 2005 21:00:14 +0000 (21:00 -0000)
* threads.c (mono_thread_attach): Call DuplicateHandle on the thread handle on win32 to make
it a real thread handle.

svn path=/trunk/mono/; revision=38731

mono/metadata/ChangeLog
mono/metadata/threads.c

index 54352138b4877979339e8353c920d3f7c9859df0..1ba3ae700e2804ade56d8ac3f4e886793e51ff12 100644 (file)
@@ -1,5 +1,8 @@
 2005-01-11  Zoltan Varga  <vargaz@freemail.hu>
 
+       * threads.c (mono_thread_attach): Call DuplicateHandle on the thread handle on win32 to make
+       it a real thread handle.
+
        * domain-internals.h: Move exvar_offset from MonoJitInfo to 
        MonoJitExceptionInfo, since each catch clause needs its own variable.
        
index ab95ae7d24621383cc87ff9d2a4bee835c40947b..8f542c608592d7350e3e24ef0f29a5d934047685 100644 (file)
@@ -394,6 +394,15 @@ mono_thread_attach (MonoDomain *domain)
 
        tid=GetCurrentThreadId ();
 
+#ifdef PLATFORM_WIN32
+       /* 
+        * The handle returned by GetCurrentThread () is a pseudo handle, so it can't be used to
+        * refer to the thread from other threads for things like aborting.
+        */
+       DuplicateHandle (GetCurrentProcess (), thread_handle, GetCurrentProcess (), &thread_handle, 
+                                        THREAD_ALL_ACCESS, TRUE, 0);
+#endif
+
        thread->handle=thread_handle;
        thread->tid=tid;
        thread->synch_lock=mono_object_new (domain, mono_defaults.object_class);