diff options
Diffstat (limited to 'src/win32/pthread.c')
| -rw-r--r-- | src/win32/pthread.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/win32/pthread.c b/src/win32/pthread.c index 105f4b89e..c78213f15 100644 --- a/src/win32/pthread.c +++ b/src/win32/pthread.c @@ -14,18 +14,23 @@ int pthread_create( void *GIT_RESTRICT arg) { GIT_UNUSED(attr); - *thread = (pthread_t) CreateThread( + *thread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, arg, 0, NULL); return *thread ? 0 : -1; } int pthread_join(pthread_t thread, void **value_ptr) { - int ret; - ret = WaitForSingleObject(thread, INFINITE); - if (ret && value_ptr) - GetExitCodeThread(thread, (void*) value_ptr); - return -(!!ret); + DWORD ret = WaitForSingleObject(thread, INFINITE); + + if (ret == WAIT_OBJECT_0) { + if (value_ptr != NULL) + GetExitCodeThread(thread, (void *)value_ptr); + CloseHandle(thread); + return 0; + } + + return -1; } int pthread_mutex_init(pthread_mutex_t *GIT_RESTRICT mutex, |
