After joining threads, the handle to the original thread should be closed as it no longer needs to be open. Signed-off-by: Seija Kijin doremylover123@xxxxxxxxx Seija Kijin (2): win32: close handles of threads that have been joined prep compat/win32/pthread.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) base-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v6 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v6 Pull-Request: https://github.com/git/git/pull/1406 Range-diff vs v5: 1: 94ed068d25b ! 1: 0b5afdb93db win32: close handles of threads that have been joined @@ Commit message After joining threads, the handle to the original thread should be closed as it no longer needs to be open. - Because this only needs to happen if the - WaitForSingleObject fails, the function was - rewritten to accommodate this change. - - The function is still POSIX compliant. + This change makes the function POSIX compliant. Signed-off-by: Seija Kijin <doremylover123@xxxxxxxxx> @@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused - return EINVAL; - default: - return err_win_to_posix(GetLastError()); -+ if (WaitForSingleObject(thread->handle, INFINITE) == WAIT_FAILED) ++ switch (WaitForSingleObject(thread->handle, INFINITE)) { ++ 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 function failed, so do not detach */ + return err_win_to_posix(GetLastError()); -+ -+ if (value_ptr) { -+ *value_ptr = thread->arg; } -+ -+ CloseHandle(thread->handle); -+ return 0; } - pthread_t pthread_self(void) -: ----------- > 2: 5b35362e5d2 prep -- gitgitgadget