]> git.ipfire.org Git - thirdparty/git.git/commitdiff
win32: close handles of threads that have been joined
authorSeija Kijin <doremylover123@gmail.com>
Tue, 3 Jan 2023 16:20:19 +0000 (16:20 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Jan 2023 06:39:47 +0000 (15:39 +0900)
After the thread terminates, the handle to the
original thread should be closed.

This change makes win32_pthread_join POSIX compliant.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/win32/pthread.c

index cf53bc61d82b9ee2a3c27f90b80433410a6445f2..85f8f7920ce48d418f4c77896004d17715582840 100644 (file)
@@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
        case WAIT_OBJECT_0:
                if (value_ptr)
                        *value_ptr = thread->arg;
+               CloseHandle(thread->handle);
                return 0;
        case WAIT_ABANDONED:
+               CloseHandle(thread->handle);
                return EINVAL;
        default:
+               /* the wait failed, so do not detach */
                return err_win_to_posix(GetLastError());
        }
 }