summaryrefslogtreecommitdiff
path: root/win32_threads.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-07-26 17:43:46 +0400
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 17:43:46 +0400
commit8c9e394bc270dbaa121f3f0af5a68c2876ab3fff (patch)
treec6e0b47bf496ae3d10f367c7130f8cdb912df8eb /win32_threads.c
parent111a44f98adde07d205c92656ad9b935ca2a39a8 (diff)
downloadbdwgc-8c9e394bc270dbaa121f3f0af5a68c2876ab3fff.tar.gz
gc6.3alpha1 tarball importgc6_3alpha1
Diffstat (limited to 'win32_threads.c')
-rwxr-xr-xwin32_threads.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/win32_threads.c b/win32_threads.c
index a2f65a5d..ff1d0662 100755
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -442,7 +442,17 @@ HANDLE WINAPI GC_CreateThread(
/* fill in ID and handle; tell child this is done */
thread_table[i].id = *lpThreadId;
- thread_table[i].handle = thread_h;
+ if (!DuplicateHandle(GetCurrentProcess(),
+ thread_h,
+ GetCurrentProcess(),
+ &thread_table[i].handle,
+ 0,
+ 0,
+ DUPLICATE_SAME_ACCESS)) {
+ DWORD last_error = GetLastError();
+ GC_printf1("Last error code: %lx\n", last_error);
+ ABORT("DuplicateHandle failed");
+ }
SetEvent (parent_ready_h);
/* wait for child to fill in stack and copy args */
@@ -630,12 +640,11 @@ static void threadDetach(DWORD thread_id) {
LOCK();
for (i = 0;
i < MAX_THREADS &&
- !thread_table[i].in_use || thread_table[i].id != thread_id;
+ (!thread_table[i].in_use || thread_table[i].id != thread_id);
i++) {}
if (i >= MAX_THREADS ) {
WARN("thread %ld not found on detach", (GC_word)thread_id);
- }
- else {
+ } else {
thread_table[i].stack = 0;
thread_table[i].in_use = FALSE;
CloseHandle(thread_table[i].handle);