{"thread":{"id":"58983","subject":"[PATCH] win32: close handles of threads that have been joined","startedAt":"2022-12-19T18:38:01Z","lastAt":"2023-01-06T12:28:05Z","messageCount":41,"participants":["Rose via GitGitGadget","Ævar Arnfjörð Bjarmason","Johannes Sixt","Seija Kijin via GitGitGadget","Junio C Hamano","René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"469306","messageId":"pull.1406.git.git.1671474876207.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":null,"subject":"[PATCH] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-19T18:34:36Z","receivedAt":"2022-12-19T18:38:01Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter joining threads, the handle to the original thread\nshould be closed as it no longer needs to be open.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    win32: close handles of threads that have been joined\n    \n    After joining threads, the handle to the original thread should be\n    closed as it no longer needs to be open.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v1\nPull-Request: https://github.com/git/git/pull/1406\n\n compat/win32/pthread.c | 22 ++++++++++++++--------\n 1 file changed, 14 insertions(+), 8 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..de89667ef70 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -39,14 +39,20 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n \tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\t/* detach the thread once the join succeeds */\n+\t\tCloseHandle(thread->handle);\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\t/* either thread is not joinable or another thread is waiting on\n+\t\t * this, so we do not detatch */\n+\t\treturn EINVAL;\n+\tdefault:\n+\tcase WAIT_FAILED:\n+\t\t/* the function failed so we do not detach */\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469315","messageId":"221219.86ili7xmd5.gmgdl@evledraar.gmail.com","threadId":"58983","inReplyTo":"pull.1406.git.git.1671474876207.gitgitgadget@gmail.com","subject":"Re: [PATCH] win32: close handles of threads that have been joined","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-12-19T18:40:37Z","receivedAt":"2022-12-19T18:46:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Dec 19 2022, Rose via GitGitGadget wrote:\n\n> From: Seija Kijin <doremylover123@gmail.com>\n>\n> After joining threads, the handle to the original thread\n> should be closed as it no longer needs to be open.\n>\n> Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n> ---\n>     win32: close handles of threads that have been joined\n>     \n>     After joining threads, the handle to the original thread should be\n>     closed as it no longer needs to be open.\n>     \n>     Signed-off-by: Seija Kijin doremylover123@gmail.com\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v1\n> Pull-Request: https://github.com/git/git/pull/1406\n>\n>  compat/win32/pthread.c | 22 ++++++++++++++--------\n>  1 file changed, 14 insertions(+), 8 deletions(-)\n>\n> diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\n> index 2e7eead42cb..de89667ef70 100644\n> --- a/compat/win32/pthread.c\n> +++ b/compat/win32/pthread.c\n> @@ -39,14 +39,20 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n>  {\n>  \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n>  \tswitch (result) {\n> -\t\tcase WAIT_OBJECT_0:\n> -\t\t\tif (value_ptr)\n> -\t\t\t\t*value_ptr = thread->arg;\n> -\t\t\treturn 0;\n> -\t\tcase WAIT_ABANDONED:\n> -\t\t\treturn EINVAL;\n> -\t\tdefault:\n> -\t\t\treturn err_win_to_posix(GetLastError());\n> +\tcase WAIT_OBJECT_0:\n> +\t\tif (value_ptr)\n> +\t\t\t*value_ptr = thread->arg;\n> +\t\t/* detach the thread once the join succeeds */\n> +\t\tCloseHandle(thread->handle);\n> +\t\treturn 0;\n> +\tcase WAIT_ABANDONED:\n> +\t\t/* either thread is not joinable or another thread is waiting on\n> +\t\t * this, so we do not detatch */\n\nSee CodingGuidelines for how multi-line comments should look like.\n\n\t/*\n\t * Like this\n\t * Another line etc.\n\t */\n> +\t\treturn EINVAL;\n> +\tdefault:\n> +\tcase WAIT_FAILED:\n> +\t\t/* the function failed so we do not detach */\n> +\t\treturn err_win_to_posix(GetLastError());\n\nThe post-image adhares to our CodingGuidelines better than the\npre-image, but please split up such re-indentation into a \"prep\" change.\nManually looking at this with \"git show -w\" shows the actual (and\nsmaller) functional change.\n\nYou add a \"case\" for WAIT_FAILED\", but keep \"default\".\n\nI have no idea about this API, but a search turned up:\nhttps://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject\n\nThat seems to suggest that it only returns 4 possible values.\n\nRather than having the \"default\" case shouldn't we (and this is just a\nsuggestion, and should be its own prep change in any case) do:\n\n\tswitch (result) {\n\tcase WAIT_OBJECT_0:\n\t\treturn ...;\n\tcase WAIT_ABANDONED:\n\t\treturn ...;\n\tcase WAIT_TIMEOUT:\n\tcase WAIT_FAILED:\n\t\treturn ...;\n\tdefault:\n\t\tBUG(\"unhandled result %d\", result);\n\t}\n\nI.e. instead of keeping \"default\" you can just list \"WAIT_TIMEOUT\".\n\nI don't know if that's OK with this API, it does say \"If the function\nsucceeds, the return value indicates, so maybe that \"default\" handles a\nlot more still?\n\n\n\n"},{"id":"469358","messageId":"a1d947ba-50ba-331b-daf6-30773d388be4@kdbg.org","threadId":"58983","inReplyTo":"pull.1406.git.git.1671474876207.gitgitgadget@gmail.com","subject":"Re: [PATCH] win32: close handles of threads that have been joined","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2022-12-20T07:53:54Z","receivedAt":"2022-12-20T07:54:02Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 19.12.22 um 19:34 schrieb Rose via GitGitGadget:\n> From: Seija Kijin <doremylover123@gmail.com>\n> \n> After joining threads, the handle to the original thread\n> should be closed as it no longer needs to be open.\n> \n> Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n> ---\n\n>  compat/win32/pthread.c | 22 ++++++++++++++--------\n>  1 file changed, 14 insertions(+), 8 deletions(-)\n> \n> diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\n> index 2e7eead42cb..de89667ef70 100644\n> --- a/compat/win32/pthread.c\n> +++ b/compat/win32/pthread.c\n> @@ -39,14 +39,20 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n>  {\n>  \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n>  \tswitch (result) {\n> -\t\tcase WAIT_OBJECT_0:\n> -\t\t\tif (value_ptr)\n> -\t\t\t\t*value_ptr = thread->arg;\n> -\t\t\treturn 0;\n> -\t\tcase WAIT_ABANDONED:\n> -\t\t\treturn EINVAL;\n> -\t\tdefault:\n> -\t\t\treturn err_win_to_posix(GetLastError());\n> +\tcase WAIT_OBJECT_0:\n> +\t\tif (value_ptr)\n> +\t\t\t*value_ptr = thread->arg;\n> +\t\t/* detach the thread once the join succeeds */\n> +\t\tCloseHandle(thread->handle);\n> +\t\treturn 0;\n\nThis is a good change. It is a severe omission that the handle was not\nclosed. (But I still have to test the patch.)\n\n> +\tcase WAIT_ABANDONED:\n> +\t\t/* either thread is not joinable or another thread is waiting on\n> +\t\t * this, so we do not detatch */\n> +\t\treturn EINVAL;\n\nI don't know which cases this mental note wants to help. Assuming that\nthe [win232_]pthread_ API is used correctly, this error cannot happen\n(WAIT_ABANDONED can only happen when WaitForSingleObject is called on a\nmutex object).\n\n> +\tdefault:\n> +\tcase WAIT_FAILED:\n> +\t\t/* the function failed so we do not detach */\n> +\t\treturn err_win_to_posix(GetLastError());\n>  \t}\n\nGood.\n\n-- Hannes\n\n"},{"id":"469389","messageId":"pull.1406.v2.git.git.1671562663899.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.git.git.1671474876207.gitgitgadget@gmail.com","subject":"[PATCH v2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-20T18:57:43Z","receivedAt":"2022-12-20T18:58:15Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter joining threads, the handle to the original thread\nshould be closed as it no longer needs to be open.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    win32: close handles of threads that have been joined\n    \n    After joining threads, the handle to the original thread should be\n    closed as it no longer needs to be open.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v2\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v1:\n\n 1:  e53b274ab4b ! 1:  8b20c4149be win32: close handles of threads that have been joined\n     @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_p\n      +\t\treturn 0;\n      +\tcase WAIT_ABANDONED:\n      +\t\t/* either thread is not joinable or another thread is waiting on\n     -+\t\t * this, so we do not detatch */\n     ++\t\t * this, so do not detatch */\n      +\t\treturn EINVAL;\n     -+\tdefault:\n      +\tcase WAIT_FAILED:\n     ++\tdefault:\n      +\t\t/* the function failed so we do not detach */\n      +\t\treturn err_win_to_posix(GetLastError());\n       \t}\n\n\n compat/win32/pthread.c | 22 ++++++++++++++--------\n 1 file changed, 14 insertions(+), 8 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..0d62c45ecc2 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -39,14 +39,20 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n \tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\t/* detach the thread once the join succeeds */\n+\t\tCloseHandle(thread->handle);\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\t/* either thread is not joinable or another thread is waiting on\n+\t\t * this, so do not detatch */\n+\t\treturn EINVAL;\n+\tcase WAIT_FAILED:\n+\tdefault:\n+\t\t/* the function failed so we do not detach */\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469390","messageId":"pull.1406.v3.git.git.1671562845014.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v2.git.git.1671562663899.gitgitgadget@gmail.com","subject":"[PATCH v3] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-20T19:00:44Z","receivedAt":"2022-12-20T19:01:10Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter joining threads, the handle to the original thread\nshould be closed as it no longer needs to be open.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    win32: close handles of threads that have been joined\n    \n    After joining threads, the handle to the original thread should be\n    closed as it no longer needs to be open.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v3\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v2:\n\n 1:  8b20c4149be ! 1:  2049576b193 win32: close handles of threads that have been joined\n     @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_p\n      +\t\treturn EINVAL;\n      +\tcase WAIT_FAILED:\n      +\tdefault:\n     -+\t\t/* the function failed so we do not detach */\n     ++\t\t/* the function failed, so do not detach */\n      +\t\treturn err_win_to_posix(GetLastError());\n       \t}\n       }\n\n\n compat/win32/pthread.c | 22 ++++++++++++++--------\n 1 file changed, 14 insertions(+), 8 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..306834a7153 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -39,14 +39,20 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n \tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\t/* detach the thread once the join succeeds */\n+\t\tCloseHandle(thread->handle);\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\t/* either thread is not joinable or another thread is waiting on\n+\t\t * this, so do not detatch */\n+\t\treturn EINVAL;\n+\tcase WAIT_FAILED:\n+\tdefault:\n+\t\t/* the function failed, so do not detach */\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469393","messageId":"pull.1406.v4.git.git.1671566641.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v3.git.git.1671562845014.gitgitgadget@gmail.com","subject":"[PATCH v4 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-20T20:03:59Z","receivedAt":"2022-12-20T20:04:07Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32: close handles of threads that have been joined\n  prep\n\n compat/win32/pthread.c | 27 ++++++++++++++++-----------\n 1 file changed, 16 insertions(+), 11 deletions(-)\n\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v4\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v3:\n\n -:  ----------- > 1:  526ef7cc339 win32: close handles of threads that have been joined\n 1:  2049576b193 ! 2:  2cb4d5c7007 win32: close handles of threads that have been joined\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    win32: close handles of threads that have been joined\n     -\n     -    After joining threads, the handle to the original thread\n     -    should be closed as it no longer needs to be open.\n     +    prep\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n       ## compat/win32/pthread.c ##\n     +@@ compat/win32/pthread.c: static unsigned __stdcall win32_start_routine(void *arg)\n     + }\n     + \n     + int pthread_create(pthread_t *thread, const void *unused,\n     +-\t\t   void *(*start_routine)(void*), void *arg)\n     ++\t\t   void *(*start_routine)(void *), void *arg)\n     + {\n     + \tthread->arg = arg;\n     + \tthread->start_routine = start_routine;\n     +-\tthread->handle = (HANDLE)\n     +-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n     ++\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n     ++\t\t\t\t\t\tthread, 0, NULL);\n     + \n     + \tif (!thread->handle)\n     + \t\treturn errno;\n      @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_ptr)\n       {\n       \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n     @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_p\n      -\t\tcase WAIT_OBJECT_0:\n      -\t\t\tif (value_ptr)\n      -\t\t\t\t*value_ptr = thread->arg;\n     +-\t\t\t/* detach the thread once the join succeeds */\n     +-\t\t\tCloseHandle(thread->handle);\n      -\t\t\treturn 0;\n      -\t\tcase WAIT_ABANDONED:\n     +-\t\t\t/* either thread is not joinable or another thread is\n     +-\t\t\t * waiting on this, so do not detatch */\n      -\t\t\treturn EINVAL;\n      -\t\tdefault:\n     +-\t\t\t/* the function failed, so do not detach */\n      -\t\t\treturn err_win_to_posix(GetLastError());\n      +\tcase WAIT_OBJECT_0:\n      +\t\tif (value_ptr)\n     @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_p\n      +\t\tCloseHandle(thread->handle);\n      +\t\treturn 0;\n      +\tcase WAIT_ABANDONED:\n     -+\t\t/* either thread is not joinable or another thread is waiting on\n     -+\t\t * this, so do not detatch */\n     ++\t\t/* either thread is not joinable or another thread is\n     ++\t\t * waiting on this, so do not detatch */\n      +\t\treturn EINVAL;\n     -+\tcase WAIT_FAILED:\n      +\tdefault:\n      +\t\t/* the function failed, so do not detach */\n      +\t\treturn err_win_to_posix(GetLastError());\n\n-- \ngitgitgadget\n"},{"id":"469394","messageId":"526ef7cc339e2832b71715869f08b32d8454d8a2.1671566641.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v4.git.git.1671566641.gitgitgadget@gmail.com","subject":"[PATCH v4 1/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-20T20:04:00Z","receivedAt":"2022-12-20T20:04:10Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter joining threads, the handle to the original thread\nshould be closed as it no longer needs to be open.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..89e89c3fe00 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -42,10 +42,15 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \t\tcase WAIT_OBJECT_0:\n \t\t\tif (value_ptr)\n \t\t\t\t*value_ptr = thread->arg;\n+\t\t\t/* detach the thread once the join succeeds */\n+\t\t\tCloseHandle(thread->handle);\n \t\t\treturn 0;\n \t\tcase WAIT_ABANDONED:\n+\t\t\t/* either thread is not joinable or another thread is\n+\t\t\t * waiting on this, so do not detatch */\n \t\t\treturn EINVAL;\n \t\tdefault:\n+\t\t\t/* the function failed, so do not detach */\n \t\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n-- \ngitgitgadget\n\n"},{"id":"469395","messageId":"2cb4d5c70072b3e3a4bfb85fe486b78b231a2a8c.1671566641.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v4.git.git.1671566641.gitgitgadget@gmail.com","subject":"[PATCH v4 2/2] prep","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-20T20:04:01Z","receivedAt":"2022-12-20T20:04:11Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 89e89c3fe00..0831ffbc3ae 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -39,19 +39,19 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n \tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\t/* detach the thread once the join succeeds */\n-\t\t\tCloseHandle(thread->handle);\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\t/* either thread is not joinable or another thread is\n-\t\t\t * waiting on this, so do not detatch */\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\t/* the function failed, so do not detach */\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\t/* detach the thread once the join succeeds */\n+\t\tCloseHandle(thread->handle);\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\t/* either thread is not joinable or another thread is\n+\t\t * waiting on this, so do not detatch */\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\t/* the function failed, so do not detach */\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n"},{"id":"469400","messageId":"pull.1406.v5.git.git.1671571084753.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v4.git.git.1671566641.gitgitgadget@gmail.com","subject":"[PATCH v5] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-20T21:18:04Z","receivedAt":"2022-12-20T21:18:13Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter joining threads, the handle to the original thread\nshould be closed as it no longer needs to be open.\n\nBecause this only needs to happen if the\nWaitForSingleObject fails, the function was\nrewritten to accommodate this change.\n\nThe function is still POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    win32: close handles of threads that have been joined\n    \n    After joining threads, the handle to the original thread should be\n    closed as it no longer needs to be open.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v5\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v4:\n\n 1:  526ef7cc339 < -:  ----------- win32: close handles of threads that have been joined\n 2:  2cb4d5c7007 ! 1:  94ed068d25b prep\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    prep\n     +    win32: close handles of threads that have been joined\n     +\n     +    After joining threads, the handle to the original thread\n     +    should be closed as it no longer needs to be open.\n     +\n     +    Because this only needs to happen if the\n     +    WaitForSingleObject fails, the function was\n     +    rewritten to accommodate this change.\n     +\n     +    The function is still POSIX compliant.\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n       ## compat/win32/pthread.c ##\n     -@@ compat/win32/pthread.c: static unsigned __stdcall win32_start_routine(void *arg)\n     - }\n     - \n     - int pthread_create(pthread_t *thread, const void *unused,\n     --\t\t   void *(*start_routine)(void*), void *arg)\n     -+\t\t   void *(*start_routine)(void *), void *arg)\n     - {\n     - \tthread->arg = arg;\n     - \tthread->start_routine = start_routine;\n     --\tthread->handle = (HANDLE)\n     --\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n     -+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n     -+\t\t\t\t\t\tthread, 0, NULL);\n     +@@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused,\n       \n     - \tif (!thread->handle)\n     - \t\treturn errno;\n     -@@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_ptr)\n     + int win32_pthread_join(pthread_t *thread, void **value_ptr)\n       {\n     - \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n     - \tswitch (result) {\n     +-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n     +-\tswitch (result) {\n      -\t\tcase WAIT_OBJECT_0:\n      -\t\t\tif (value_ptr)\n      -\t\t\t\t*value_ptr = thread->arg;\n     --\t\t\t/* detach the thread once the join succeeds */\n     --\t\t\tCloseHandle(thread->handle);\n      -\t\t\treturn 0;\n      -\t\tcase WAIT_ABANDONED:\n     --\t\t\t/* either thread is not joinable or another thread is\n     --\t\t\t * waiting on this, so do not detatch */\n      -\t\t\treturn EINVAL;\n      -\t\tdefault:\n     --\t\t\t/* the function failed, so do not detach */\n      -\t\t\treturn err_win_to_posix(GetLastError());\n     -+\tcase WAIT_OBJECT_0:\n     -+\t\tif (value_ptr)\n     -+\t\t\t*value_ptr = thread->arg;\n     -+\t\t/* detach the thread once the join succeeds */\n     -+\t\tCloseHandle(thread->handle);\n     -+\t\treturn 0;\n     -+\tcase WAIT_ABANDONED:\n     -+\t\t/* either thread is not joinable or another thread is\n     -+\t\t * waiting on this, so do not detatch */\n     -+\t\treturn EINVAL;\n     -+\tdefault:\n     -+\t\t/* the function failed, so do not detach */\n     ++\tif (WaitForSingleObject(thread->handle, INFINITE) == WAIT_FAILED)\n      +\t\treturn err_win_to_posix(GetLastError());\n     ++\n     ++\tif (value_ptr) {\n     ++\t\t*value_ptr = thread->arg;\n       \t}\n     ++\n     ++\tCloseHandle(thread->handle);\n     ++\treturn 0;\n       }\n       \n     + pthread_t pthread_self(void)\n\n\n compat/win32/pthread.c | 18 ++++++++----------\n 1 file changed, 8 insertions(+), 10 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..7f8503b4b50 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -37,17 +37,15 @@ int pthread_create(pthread_t *thread, const void *unused,\n \n int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n-\tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tif (WaitForSingleObject(thread->handle, INFINITE) == WAIT_FAILED)\n+\t\treturn err_win_to_posix(GetLastError());\n+\n+\tif (value_ptr) {\n+\t\t*value_ptr = thread->arg;\n \t}\n+\n+\tCloseHandle(thread->handle);\n+\treturn 0;\n }\n \n pthread_t pthread_self(void)\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469402","messageId":"4c4f7723-b1fa-846b-75ee-c37c61048ed8@kdbg.org","threadId":"58983","inReplyTo":"pull.1406.v5.git.git.1671571084753.gitgitgadget@gmail.com","subject":"Re: [PATCH v5] win32: close handles of threads that have been joined","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2022-12-20T22:06:01Z","receivedAt":"2022-12-20T22:06:10Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 20.12.22 um 22:18 schrieb Rose via GitGitGadget:\n> From: Seija Kijin <doremylover123@gmail.com>\n> \n> After joining threads, the handle to the original thread\n> should be closed as it no longer needs to be open.\n> \n> Because this only needs to happen if the\n> WaitForSingleObject fails, the function was\n> rewritten to accommodate this change.\n\nThis sentence says that the handle must be closed only when\nWaitForSingleObject fails. But my understanding is that we must close it\nwhen the call is successful. In fact, that is what you implemented.\n\n> The function is still POSIX compliant.\n> \n> Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n> ---\n\n> \n>  compat/win32/pthread.c | 18 ++++++++----------\n>  1 file changed, 8 insertions(+), 10 deletions(-)\n> \n> diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\n> index 2e7eead42cb..7f8503b4b50 100644\n> --- a/compat/win32/pthread.c\n> +++ b/compat/win32/pthread.c\n> @@ -37,17 +37,15 @@ int pthread_create(pthread_t *thread, const void *unused,\n>  \n>  int win32_pthread_join(pthread_t *thread, void **value_ptr)\n>  {\n> -\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n> -\tswitch (result) {\n> -\t\tcase WAIT_OBJECT_0:\n> -\t\t\tif (value_ptr)\n> -\t\t\t\t*value_ptr = thread->arg;\n> -\t\t\treturn 0;\n> -\t\tcase WAIT_ABANDONED:\n> -\t\t\treturn EINVAL;\n> -\t\tdefault:\n> -\t\t\treturn err_win_to_posix(GetLastError());\n> +\tif (WaitForSingleObject(thread->handle, INFINITE) == WAIT_FAILED)\n> +\t\treturn err_win_to_posix(GetLastError());\n> +\n> +\tif (value_ptr) {\n> +\t\t*value_ptr = thread->arg;\n>  \t}\n> +\n> +\tCloseHandle(thread->handle);\n> +\treturn 0;\n\nGenerally, such rewrites are not welcome if there is no obvious value in\nthe new code structure. To my eyes, the original switch statement is\nmuch clearer than the new structure. In particular, the good case is\nwhen the result is WAIT_OBJECT_0. The switch statement clearly handles\nthe case. The new code, however, loses the handling of a buggy caller,\nWAIT_ABANONED, and handles it like a success case.\n\nWhat is wrong with just inserting a CloseHandle() call at the right spot\nin the original code and no other change?\n\n>  }\n>  \n>  pthread_t pthread_self(void)\n\n\n-- Hannes\n\n"},{"id":"469416","messageId":"pull.1406.v6.git.git.1671597317.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v5.git.git.1671571084753.gitgitgadget@gmail.com","subject":"[PATCH v6 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-21T04:35:15Z","receivedAt":"2022-12-21T04:35:26Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32: close handles of threads that have been joined\n  prep\n\n compat/win32/pthread.c | 28 +++++++++++++++-------------\n 1 file changed, 15 insertions(+), 13 deletions(-)\n\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v6\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v6\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v5:\n\n 1:  94ed068d25b ! 1:  0b5afdb93db win32: close handles of threads that have been joined\n     @@ Commit message\n          After joining threads, the handle to the original thread\n          should be closed as it no longer needs to be open.\n      \n     -    Because this only needs to happen if the\n     -    WaitForSingleObject fails, the function was\n     -    rewritten to accommodate this change.\n     -\n     -    The function is still POSIX compliant.\n     +    This change makes the function POSIX compliant.\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n     @@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused\n      -\t\t\treturn EINVAL;\n      -\t\tdefault:\n      -\t\t\treturn err_win_to_posix(GetLastError());\n     -+\tif (WaitForSingleObject(thread->handle, INFINITE) == WAIT_FAILED)\n     ++\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n     ++\tcase WAIT_OBJECT_0:\n     ++\t\tif (value_ptr)\n     ++\t\t\t*value_ptr = thread->arg;\n     ++\t\tCloseHandle(thread->handle);\n     ++\t\treturn 0;\n     ++\tcase WAIT_ABANDONED:\n     ++\t\tCloseHandle(thread->handle);\n     ++\t\treturn EINVAL;\n     ++\tdefault:\n     ++\t\t/* the function failed, so do not detach */\n      +\t\treturn err_win_to_posix(GetLastError());\n     -+\n     -+\tif (value_ptr) {\n     -+\t\t*value_ptr = thread->arg;\n       \t}\n     -+\n     -+\tCloseHandle(thread->handle);\n     -+\treturn 0;\n       }\n       \n     - pthread_t pthread_self(void)\n -:  ----------- > 2:  5b35362e5d2 prep\n\n-- \ngitgitgadget\n"},{"id":"469417","messageId":"0b5afdb93dbf20e8467368be77779b89201a0cad.1671597317.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v6.git.git.1671597317.gitgitgadget@gmail.com","subject":"[PATCH v6 1/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-21T04:35:16Z","receivedAt":"2022-12-21T04:35:30Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter joining threads, the handle to the original thread\nshould be closed as it no longer needs to be open.\n\nThis change makes the function POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 22 ++++++++++++----------\n 1 file changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..cf94b4491f9 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -37,16 +37,18 @@ int pthread_create(pthread_t *thread, const void *unused,\n \n int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n-\tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\t/* the function failed, so do not detach */\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"469418","messageId":"5b35362e5d2d2a6883206bd21e95c1629127c9f8.1671597317.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v6.git.git.1671597317.gitgitgadget@gmail.com","subject":"[PATCH v6 2/2] prep","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-21T04:35:17Z","receivedAt":"2022-12-21T04:35:34Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex cf94b4491f9..fc88ce20e2b 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n-- \ngitgitgadget\n"},{"id":"469419","messageId":"pull.1406.v7.git.git.1671598008.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v6.git.git.1671597317.gitgitgadget@gmail.com","subject":"[PATCH v7 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-21T04:46:46Z","receivedAt":"2022-12-21T04:47:10Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32: close handles of threads that have been joined\n  prep\n\n compat/win32/pthread.c | 28 +++++++++++++++-------------\n 1 file changed, 15 insertions(+), 13 deletions(-)\n\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v7\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v7\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v6:\n\n -:  ----------- > 1:  b40287508df win32: close handles of threads that have been joined\n 1:  0b5afdb93db ! 2:  f780ed525eb win32: close handles of threads that have been joined\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    win32: close handles of threads that have been joined\n     -\n     -    After joining threads, the handle to the original thread\n     -    should be closed as it no longer needs to be open.\n     -\n     -    This change makes the function POSIX compliant.\n     +    prep\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n       ## compat/win32/pthread.c ##\n     +@@ compat/win32/pthread.c: static unsigned __stdcall win32_start_routine(void *arg)\n     + }\n     + \n     + int pthread_create(pthread_t *thread, const void *unused,\n     +-\t\t   void *(*start_routine)(void*), void *arg)\n     ++\t\t   void *(*start_routine)(void *), void *arg)\n     + {\n     + \tthread->arg = arg;\n     + \tthread->start_routine = start_routine;\n     +-\tthread->handle = (HANDLE)\n     +-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n     ++\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n     ++\t\t\t\t\t\tthread, 0, NULL);\n     + \n     + \tif (!thread->handle)\n     + \t\treturn errno;\n      @@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused,\n       \n       int win32_pthread_join(pthread_t *thread, void **value_ptr)\n     @@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused\n      -\t\tcase WAIT_OBJECT_0:\n      -\t\t\tif (value_ptr)\n      -\t\t\t\t*value_ptr = thread->arg;\n     +-\t\t\tCloseHandle(thread->handle);\n      -\t\t\treturn 0;\n      -\t\tcase WAIT_ABANDONED:\n     +-\t\t\tCloseHandle(thread->handle);\n      -\t\t\treturn EINVAL;\n      -\t\tdefault:\n     +-\t\t\t/* the function failed, so do not detach */\n      -\t\t\treturn err_win_to_posix(GetLastError());\n      +\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n      +\tcase WAIT_OBJECT_0:\n 2:  5b35362e5d2 < -:  ----------- prep\n\n-- \ngitgitgadget\n"},{"id":"469420","messageId":"f780ed525eb2db09a7e56efa98adae22d5a9f244.1671598008.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v7.git.git.1671598008.gitgitgadget@gmail.com","subject":"[PATCH v7 2/2] prep","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-21T04:46:48Z","receivedAt":"2022-12-21T04:47:10Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 31 +++++++++++++++----------------\n 1 file changed, 15 insertions(+), 16 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 21c705778b6..fc88ce20e2b 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -37,19 +37,18 @@ int pthread_create(pthread_t *thread, const void *unused,\n \n int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n-\tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\tCloseHandle(thread->handle);\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\tCloseHandle(thread->handle);\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\t/* the function failed, so do not detach */\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\t/* the function failed, so do not detach */\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n"},{"id":"469421","messageId":"b40287508dfa9dc3013828f011c8729d8f8eb972.1671598008.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v7.git.git.1671598008.gitgitgadget@gmail.com","subject":"[PATCH v7 1/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-21T04:46:47Z","receivedAt":"2022-12-21T04:47:10Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..21c705778b6 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \t\tcase WAIT_OBJECT_0:\n \t\t\tif (value_ptr)\n \t\t\t\t*value_ptr = thread->arg;\n+\t\t\tCloseHandle(thread->handle);\n \t\t\treturn 0;\n \t\tcase WAIT_ABANDONED:\n+\t\t\tCloseHandle(thread->handle);\n \t\t\treturn EINVAL;\n \t\tdefault:\n+\t\t\t/* the function failed, so do not detach */\n \t\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n-- \ngitgitgadget\n\n"},{"id":"469450","messageId":"559648b5-5acc-ef8f-3c72-69163ffd7b52@kdbg.org","threadId":"58983","inReplyTo":"b40287508dfa9dc3013828f011c8729d8f8eb972.1671598008.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v7 1/2] win32: close handles of threads that have been joined","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2022-12-22T07:52:29Z","receivedAt":"2022-12-22T07:52:43Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 21.12.22 um 05:46 schrieb Seija Kijin via GitGitGadget:\n> From: Seija Kijin <doremylover123@gmail.com>\n> \n> After the thread terminates, the handle to the\n> original thread should be closed.\n> \n> This change makes win32_pthread_join POSIX compliant.\n> \n> Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n> ---\n>  compat/win32/pthread.c | 3 +++\n>  1 file changed, 3 insertions(+)\n> \n> diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\n> index 2e7eead42cb..21c705778b6 100644\n> --- a/compat/win32/pthread.c\n> +++ b/compat/win32/pthread.c\n> @@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n>  \t\tcase WAIT_OBJECT_0:\n>  \t\t\tif (value_ptr)\n>  \t\t\t\t*value_ptr = thread->arg;\n> +\t\t\tCloseHandle(thread->handle);\n>  \t\t\treturn 0;\n>  \t\tcase WAIT_ABANDONED:\n> +\t\t\tCloseHandle(thread->handle);\n>  \t\t\treturn EINVAL;\n>  \t\tdefault:\n> +\t\t\t/* the function failed, so do not detach */\n>  \t\t\treturn err_win_to_posix(GetLastError());\n>  \t}\n>  }\n\nThis patch looks good. It passes the test suite on Windows. Hence:\n\nAcked-by: Johannes Sixt <j6t@kdbg.org>\n\nThe follow-up patch in this thread, though, has an incomplete subject\nline and no motivation. It is not ready to be picked up.\n\n-- Hannes\n\n"},{"id":"469469","messageId":"pull.1406.v8.git.git.1671724911188.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v7.git.git.1671598008.gitgitgadget@gmail.com","subject":"[PATCH v8] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-22T16:01:51Z","receivedAt":"2022-12-22T16:02:09Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    win32: close handles of threads that have been joined\n    \n    After joining threads, the handle to the original thread should be\n    closed as it no longer needs to be open.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v8\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v8\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v7:\n\n 1:  b40287508df = 1:  70588032eb3 win32: close handles of threads that have been joined\n 2:  f780ed525eb < -:  ----------- prep\n\n\n compat/win32/pthread.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..21c705778b6 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \t\tcase WAIT_OBJECT_0:\n \t\t\tif (value_ptr)\n \t\t\t\t*value_ptr = thread->arg;\n+\t\t\tCloseHandle(thread->handle);\n \t\t\treturn 0;\n \t\tcase WAIT_ABANDONED:\n+\t\t\tCloseHandle(thread->handle);\n \t\t\treturn EINVAL;\n \t\tdefault:\n+\t\t\t/* the function failed, so do not detach */\n \t\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\n-- \ngitgitgadget\n"},{"id":"469470","messageId":"pull.1406.v9.git.git.1671729453.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v8.git.git.1671724911188.gitgitgadget@gmail.com","subject":"[PATCH v9 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-22T17:17:31Z","receivedAt":"2022-12-22T17:17:39Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32: close handles of threads that have been joined\n  prep: reformat pthread.c to fit coding guidelines\n\n compat/win32/pthread.c | 28 +++++++++++++++-------------\n 1 file changed, 15 insertions(+), 13 deletions(-)\n\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v9\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v9\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v8:\n\n 1:  70588032eb3 ! 1:  d9b1df22e03 win32: close handles of threads that have been joined\n     @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_p\n      +\t\t\tCloseHandle(thread->handle);\n       \t\t\treturn EINVAL;\n       \t\tdefault:\n     -+\t\t\t/* the function failed, so do not detach */\n     ++\t\t\t/* the wait failed, so do not detach */\n       \t\t\treturn err_win_to_posix(GetLastError());\n       \t}\n       }\n -:  ----------- > 2:  4c82a16a995 prep: reformat pthread.c to fit coding guidelines\n\n-- \ngitgitgadget\n"},{"id":"469471","messageId":"4c82a16a9950b67416530249157332a6b2afa839.1671729453.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v9.git.git.1671729453.gitgitgadget@gmail.com","subject":"[PATCH v9 2/2] prep: reformat pthread.c to fit coding guidelines","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-22T17:17:33Z","receivedAt":"2022-12-22T17:17:47Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThe motivation for this change is that\nthe post-image better fits the coding\nguidelines, especially since this file\nwas changed.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 31 +++++++++++++++----------------\n 1 file changed, 15 insertions(+), 16 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 81178ed93b7..83e088dff0a 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -37,19 +37,18 @@ int pthread_create(pthread_t *thread, const void *unused,\n \n int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n-\tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\tCloseHandle(thread->handle);\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\tCloseHandle(thread->handle);\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\t/* the wait failed, so do not detach */\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\t/* the wait failed, so do not detach */\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n"},{"id":"469472","messageId":"d9b1df22e0390efef784ace62785dc5f8c248ed6.1671729453.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v9.git.git.1671729453.gitgitgadget@gmail.com","subject":"[PATCH v9 1/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-22T17:17:32Z","receivedAt":"2022-12-22T17:17:47Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..81178ed93b7 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \t\tcase WAIT_OBJECT_0:\n \t\t\tif (value_ptr)\n \t\t\t\t*value_ptr = thread->arg;\n+\t\t\tCloseHandle(thread->handle);\n \t\t\treturn 0;\n \t\tcase WAIT_ABANDONED:\n+\t\t\tCloseHandle(thread->handle);\n \t\t\treturn EINVAL;\n \t\tdefault:\n+\t\t\t/* the wait failed, so do not detach */\n \t\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n-- \ngitgitgadget\n\n"},{"id":"469487","messageId":"xmqqa63erio9.fsf@gitster.g","threadId":"58983","inReplyTo":"4c82a16a9950b67416530249157332a6b2afa839.1671729453.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v9 2/2] prep: reformat pthread.c to fit coding guidelines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-23T01:51:50Z","receivedAt":"2022-12-23T01:51:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Seija Kijin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Subject: Re: [PATCH v9 2/2] prep: reformat pthread.c to fit coding guidelines\n\nI am guessing that you meant to have \"prep\" stand for \"preparation\"\n(which by the way is not a good thing to have instead of <area>:\nprefix).  Perhaps \"windows-pthread:\" or something?\n\nIn any case, this step should be done first, i.e. [1/2] of a\ntwo-patch series, as a preparation for the real change, I would\nthink.\n\n"},{"id":"469492","messageId":"pull.1406.v10.git.git.1671822955.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v9.git.git.1671729453.gitgitgadget@gmail.com","subject":"[PATCH v10 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:15:53Z","receivedAt":"2022-12-23T19:16:02Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32-pthread: prepare pthread.c for change by formatting\n  win32: close handles of threads that have been joined\n\n compat/win32/pthread.c | 28 +++++++++++++++-------------\n 1 file changed, 15 insertions(+), 13 deletions(-)\n\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v10\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v10\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v9:\n\n 2:  4c82a16a995 ! 1:  e0cc43efc6c prep: reformat pthread.c to fit coding guidelines\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    prep: reformat pthread.c to fit coding guidelines\n     +    win32-pthread: prepare pthread.c for change by formatting\n      \n     -    The motivation for this change is that\n     -    the post-image better fits the coding\n     -    guidelines, especially since this file\n     -    was changed.\n     +    File has been formatted to meet coding guidelines\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n     @@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused\n      -\t\tcase WAIT_OBJECT_0:\n      -\t\t\tif (value_ptr)\n      -\t\t\t\t*value_ptr = thread->arg;\n     --\t\t\tCloseHandle(thread->handle);\n      -\t\t\treturn 0;\n      -\t\tcase WAIT_ABANDONED:\n     --\t\t\tCloseHandle(thread->handle);\n      -\t\t\treturn EINVAL;\n      -\t\tdefault:\n     --\t\t\t/* the wait failed, so do not detach */\n      -\t\t\treturn err_win_to_posix(GetLastError());\n      +\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n      +\tcase WAIT_OBJECT_0:\n      +\t\tif (value_ptr)\n      +\t\t\t*value_ptr = thread->arg;\n     -+\t\tCloseHandle(thread->handle);\n      +\t\treturn 0;\n      +\tcase WAIT_ABANDONED:\n     -+\t\tCloseHandle(thread->handle);\n      +\t\treturn EINVAL;\n      +\tdefault:\n     -+\t\t/* the wait failed, so do not detach */\n      +\t\treturn err_win_to_posix(GetLastError());\n       \t}\n       }\n 1:  d9b1df22e03 ! 2:  d05d4c2e4b2 win32: close handles of threads that have been joined\n     @@ Commit message\n      \n       ## compat/win32/pthread.c ##\n      @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_ptr)\n     - \t\tcase WAIT_OBJECT_0:\n     - \t\t\tif (value_ptr)\n     - \t\t\t\t*value_ptr = thread->arg;\n     -+\t\t\tCloseHandle(thread->handle);\n     - \t\t\treturn 0;\n     - \t\tcase WAIT_ABANDONED:\n     -+\t\t\tCloseHandle(thread->handle);\n     - \t\t\treturn EINVAL;\n     - \t\tdefault:\n     -+\t\t\t/* the wait failed, so do not detach */\n     - \t\t\treturn err_win_to_posix(GetLastError());\n     + \tcase WAIT_OBJECT_0:\n     + \t\tif (value_ptr)\n     + \t\t\t*value_ptr = thread->arg;\n     ++\t\tCloseHandle(thread->handle);\n     + \t\treturn 0;\n     + \tcase WAIT_ABANDONED:\n     ++\t\tCloseHandle(thread->handle);\n     + \t\treturn EINVAL;\n     + \tdefault:\n     ++\t\t/* the wait failed, so do not detach */\n     + \t\treturn err_win_to_posix(GetLastError());\n       \t}\n       }\n\n-- \ngitgitgadget\n"},{"id":"469493","messageId":"e0cc43efc6c498706559ae4fc71c597a6481f64c.1671822955.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v10.git.git.1671822955.gitgitgadget@gmail.com","subject":"[PATCH v10 1/2] win32-pthread: prepare pthread.c for change by formatting","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:15:54Z","receivedAt":"2022-12-23T19:16:03Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFile has been formatted to meet coding guidelines\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 25 ++++++++++++-------------\n 1 file changed, 12 insertions(+), 13 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..65e15a560d5 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -37,16 +37,15 @@ int pthread_create(pthread_t *thread, const void *unused,\n \n int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n-\tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"469494","messageId":"d05d4c2e4b2e84dc8432ddf116fbcee14b0cf7e8.1671822955.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v10.git.git.1671822955.gitgitgadget@gmail.com","subject":"[PATCH v10 2/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:15:55Z","receivedAt":"2022-12-23T19:16:26Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 65e15a560d5..83e088dff0a 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -41,10 +41,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \tcase WAIT_OBJECT_0:\n \t\tif (value_ptr)\n \t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n \t\treturn 0;\n \tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n \t\treturn EINVAL;\n \tdefault:\n+\t\t/* the wait failed, so do not detach */\n \t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n-- \ngitgitgadget\n"},{"id":"469495","messageId":"pull.1406.v11.git.git.1671823177.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v10.git.git.1671822955.gitgitgadget@gmail.com","subject":"[PATCH v11 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:19:35Z","receivedAt":"2022-12-23T19:19:43Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32-pthread: prepare pthread.c for change by formatting\n  win32: close handles of threads that have been joined\n\n compat/win32/pthread.c | 29 ++++++++++++++++-------------\n 1 file changed, 16 insertions(+), 13 deletions(-)\n\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v11\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v11\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v10:\n\n 1:  e0cc43efc6c = 1:  e0cc43efc6c win32-pthread: prepare pthread.c for change by formatting\n 2:  d05d4c2e4b2 ! 2:  c5d2ddad166 win32: close handles of threads that have been joined\n     @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_p\n      +\t\tCloseHandle(thread->handle);\n       \t\treturn EINVAL;\n       \tdefault:\n     +-\t\treturn err_win_to_posix(GetLastError());\n      +\t\t/* the wait failed, so do not detach */\n     - \t\treturn err_win_to_posix(GetLastError());\n     ++\t\terrno = err_win_to_posix(GetLastError());\n     ++\t\treturn errno;\n       \t}\n       }\n     + \n\n-- \ngitgitgadget\n"},{"id":"469496","messageId":"e0cc43efc6c498706559ae4fc71c597a6481f64c.1671823177.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v11.git.git.1671823177.gitgitgadget@gmail.com","subject":"[PATCH v11 1/2] win32-pthread: prepare pthread.c for change by formatting","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:19:36Z","receivedAt":"2022-12-23T19:19:45Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFile has been formatted to meet coding guidelines\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 25 ++++++++++++-------------\n 1 file changed, 12 insertions(+), 13 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..65e15a560d5 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -37,16 +37,15 @@ int pthread_create(pthread_t *thread, const void *unused,\n \n int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n-\tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"469497","messageId":"c5d2ddad166165d1ac8975ce6d06c16eb3b6b6cb.1671823177.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v11.git.git.1671823177.gitgitgadget@gmail.com","subject":"[PATCH v11 2/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-23T19:19:37Z","receivedAt":"2022-12-23T19:19:48Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 65e15a560d5..f63f65c9dfe 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -41,11 +41,15 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \tcase WAIT_OBJECT_0:\n \t\tif (value_ptr)\n \t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n \t\treturn 0;\n \tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n \t\treturn EINVAL;\n \tdefault:\n-\t\treturn err_win_to_posix(GetLastError());\n+\t\t/* the wait failed, so do not detach */\n+\t\terrno = err_win_to_posix(GetLastError());\n+\t\treturn errno;\n \t}\n }\n \n-- \ngitgitgadget\n"},{"id":"469505","messageId":"36ac4180-9d8a-1453-c01e-9870481bbe9a@web.de","threadId":"58983","inReplyTo":"c5d2ddad166165d1ac8975ce6d06c16eb3b6b6cb.1671823177.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v11 2/2] win32: close handles of threads that have been joined","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2022-12-24T07:50:57Z","receivedAt":"2022-12-24T07:51:08Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 23.12.22 um 20:19 schrieb Seija Kijin via GitGitGadget:\n> From: Seija Kijin <doremylover123@gmail.com>\n>\n> After the thread terminates, the handle to the\n> original thread should be closed.\n>\n> This change makes win32_pthread_join POSIX compliant.\n>\n> Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n> ---\n>  compat/win32/pthread.c | 6 +++++-\n>  1 file changed, 5 insertions(+), 1 deletion(-)\n>\n> diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\n> index 65e15a560d5..f63f65c9dfe 100644\n> --- a/compat/win32/pthread.c\n> +++ b/compat/win32/pthread.c\n> @@ -41,11 +41,15 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n>  \tcase WAIT_OBJECT_0:\n>  \t\tif (value_ptr)\n>  \t\t\t*value_ptr = thread->arg;\n> +\t\tCloseHandle(thread->handle);\n>  \t\treturn 0;\n>  \tcase WAIT_ABANDONED:\n> +\t\tCloseHandle(thread->handle);\n>  \t\treturn EINVAL;\n>  \tdefault:\n> -\t\treturn err_win_to_posix(GetLastError());\n> +\t\t/* the wait failed, so do not detach */\n> +\t\terrno = err_win_to_posix(GetLastError());\n> +\t\treturn errno;\n\nWhy do we need to set errno?  That's the only difference to v10, but I\ndidn't find an explanation.  POSIX only mentions the return value:\nhttps://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html\n\n>  \t}\n>  }\n>\n\n"},{"id":"469513","messageId":"fa5cbfa5e0ca86e2143346068c9b99856cdded0c.1671932405.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v12.git.git.1671932405.gitgitgadget@gmail.com","subject":"[PATCH v12 2/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-25T01:40:05Z","receivedAt":"2022-12-25T01:40:20Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 65e15a560d5..83e088dff0a 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -41,10 +41,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \tcase WAIT_OBJECT_0:\n \t\tif (value_ptr)\n \t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n \t\treturn 0;\n \tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n \t\treturn EINVAL;\n \tdefault:\n+\t\t/* the wait failed, so do not detach */\n \t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n-- \ngitgitgadget\n"},{"id":"469514","messageId":"pull.1406.v12.git.git.1671932405.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v11.git.git.1671823177.gitgitgadget@gmail.com","subject":"[PATCH v12 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-25T01:40:03Z","receivedAt":"2022-12-25T01:40:20Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32-pthread: prepare pthread.c for change by formatting\n  win32: close handles of threads that have been joined\n\n compat/win32/pthread.c | 28 +++++++++++++++-------------\n 1 file changed, 15 insertions(+), 13 deletions(-)\n\n\nbase-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v12\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v12\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v11:\n\n 1:  e0cc43efc6c = 1:  e0cc43efc6c win32-pthread: prepare pthread.c for change by formatting\n 2:  c5d2ddad166 ! 2:  fa5cbfa5e0c win32: close handles of threads that have been joined\n     @@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_p\n      +\t\tCloseHandle(thread->handle);\n       \t\treturn EINVAL;\n       \tdefault:\n     --\t\treturn err_win_to_posix(GetLastError());\n      +\t\t/* the wait failed, so do not detach */\n     -+\t\terrno = err_win_to_posix(GetLastError());\n     -+\t\treturn errno;\n     + \t\treturn err_win_to_posix(GetLastError());\n       \t}\n       }\n     - \n\n-- \ngitgitgadget\n"},{"id":"469515","messageId":"e0cc43efc6c498706559ae4fc71c597a6481f64c.1671932405.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v12.git.git.1671932405.gitgitgadget@gmail.com","subject":"[PATCH v12 1/2] win32-pthread: prepare pthread.c for change by formatting","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-25T01:40:04Z","receivedAt":"2022-12-25T01:40:20Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFile has been formatted to meet coding guidelines\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 25 ++++++++++++-------------\n 1 file changed, 12 insertions(+), 13 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..65e15a560d5 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -37,16 +37,15 @@ int pthread_create(pthread_t *thread, const void *unused,\n \n int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n-\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n-\tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"469533","messageId":"xmqqmt7blzju.fsf@gitster.g","threadId":"58983","inReplyTo":"e0cc43efc6c498706559ae4fc71c597a6481f64c.1671932405.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v12 1/2] win32-pthread: prepare pthread.c for change by formatting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-26T01:32:53Z","receivedAt":"2022-12-26T01:41:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Seija Kijin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n>  int pthread_create(pthread_t *thread, const void *unused,\n> -\t\t   void *(*start_routine)(void*), void *arg)\n> +\t\t   void *(*start_routine)(void *), void *arg)\n\nGood.\n\n>  {\n>  \tthread->arg = arg;\n>  \tthread->start_routine = start_routine;\n> -\tthread->handle = (HANDLE)\n> -\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n> +\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n> +\t\t\t\t\t\tthread, 0, NULL);\n\nI would say this is good either way---preimage may slightly be\neasier to read, but it is not worth a patch churn.\n\n> -\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n> -\tswitch (result) {\n> -\t\tcase WAIT_OBJECT_0:\n> -\t\t\tif (value_ptr)\n> -\t\t\t\t*value_ptr = thread->arg;\n> -\t\t\treturn 0;\n> -\t\tcase WAIT_ABANDONED:\n> -\t\t\treturn EINVAL;\n> -\t\tdefault:\n> -\t\t\treturn err_win_to_posix(GetLastError());\n> +\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n> +\tcase WAIT_OBJECT_0:\n> +\t\tif (value_ptr)\n> +\t\t\t*value_ptr = thread->arg;\n> +\t\treturn 0;\n> +\tcase WAIT_ABANDONED:\n> +\t\treturn EINVAL;\n> +\tdefault:\n> +\t\treturn err_win_to_posix(GetLastError());\n>  \t}\n>  }\n\nLoss of a single-use variable is, strictly speaking, a \"while at it\"\nchange that has nothing to do with \"reformatting\", but otherwise the\nresult of the hunk looks good.\n\nWill queue.\n\nThanks.\n\n\n\nP.S.  An address that is designed to bounce or sent to black hole\nappears on the CC: of the original e-mail message.  Can you stop\ndoing that (or is that what GGG does without user's control)?\n\n  Rose <83477269+AtariDreams@users.noreply.github.com>\n"},{"id":"469534","messageId":"xmqqilhynciq.fsf@gitster.g","threadId":"58983","inReplyTo":"fa5cbfa5e0ca86e2143346068c9b99856cdded0c.1671932405.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v12 2/2] win32: close handles of threads that have been joined","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-26T02:07:25Z","receivedAt":"2022-12-26T02:07:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Seija Kijin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\n> index 65e15a560d5..83e088dff0a 100644\n> --- a/compat/win32/pthread.c\n> +++ b/compat/win32/pthread.c\n> @@ -41,10 +41,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n>  \tcase WAIT_OBJECT_0:\n>  \t\tif (value_ptr)\n>  \t\t\t*value_ptr = thread->arg;\n> +\t\tCloseHandle(thread->handle);\n>  \t\treturn 0;\n>  \tcase WAIT_ABANDONED:\n> +\t\tCloseHandle(thread->handle);\n>  \t\treturn EINVAL;\n>  \tdefault:\n> +\t\t/* the wait failed, so do not detach */\n>  \t\treturn err_win_to_posix(GetLastError());\n>  \t}\n>  }\n\nThis matches what got an Ack from J6t in v7, so I'll queue with\nAcked-by: added.  Thanks.\n"},{"id":"469767","messageId":"pull.1406.v13.git.git.1672762819.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v12.git.git.1671932405.gitgitgadget@gmail.com","subject":"[PATCH v13 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-03T16:20:17Z","receivedAt":"2023-01-03T16:20:50Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32: prepare pthread.c for change by formatting\n  win32: close handles of threads that have been joined\n\n compat/win32/pthread.c | 25 ++++++++++++++-----------\n 1 file changed, 14 insertions(+), 11 deletions(-)\n\n\nbase-commit: 2b4f5a4e4bb102ac8d967cea653ed753b608193c\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v13\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v13\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v12:\n\n 1:  e0cc43efc6c ! 1:  6f89b120641 win32-pthread: prepare pthread.c for change by formatting\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    win32-pthread: prepare pthread.c for change by formatting\n     +    win32: prepare pthread.c for change by formatting\n      \n     -    File has been formatted to meet coding guidelines\n     +    File has been formatted to meet coding guidelines.\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n     @@ compat/win32/pthread.c: static unsigned __stdcall win32_start_routine(void *arg)\n       \n       \tif (!thread->handle)\n       \t\treturn errno;\n     -@@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused,\n     - \n     - int win32_pthread_join(pthread_t *thread, void **value_ptr)\n     +@@ compat/win32/pthread.c: int win32_pthread_join(pthread_t *thread, void **value_ptr)\n       {\n     --\tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n     --\tswitch (result) {\n     + \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n     + \tswitch (result) {\n      -\t\tcase WAIT_OBJECT_0:\n      -\t\t\tif (value_ptr)\n      -\t\t\t\t*value_ptr = thread->arg;\n     @@ compat/win32/pthread.c: int pthread_create(pthread_t *thread, const void *unused\n      -\t\t\treturn EINVAL;\n      -\t\tdefault:\n      -\t\t\treturn err_win_to_posix(GetLastError());\n     -+\tswitch (WaitForSingleObject(thread->handle, INFINITE)) {\n      +\tcase WAIT_OBJECT_0:\n      +\t\tif (value_ptr)\n      +\t\t\t*value_ptr = thread->arg;\n 2:  fa5cbfa5e0c = 2:  f126d6416d5 win32: close handles of threads that have been joined\n\n-- \ngitgitgadget\n"},{"id":"469768","messageId":"6f89b1206418771b5a7c9a5a79b91b0f21b516df.1672762819.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v13.git.git.1672762819.gitgitgadget@gmail.com","subject":"[PATCH v13 1/2] win32: prepare pthread.c for change by formatting","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-03T16:20:18Z","receivedAt":"2023-01-03T16:21:18Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFile has been formatted to meet coding guidelines.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..cf53bc61d82 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -39,14 +39,14 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n \tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"469769","messageId":"f126d6416d5eb00f3051c5dfd6f16d013d708caa.1672762819.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v13.git.git.1672762819.gitgitgadget@gmail.com","subject":"[PATCH v13 2/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-03T16:20:19Z","receivedAt":"2023-01-03T16:21:18Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex cf53bc61d82..85f8f7920ce 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \tcase WAIT_OBJECT_0:\n \t\tif (value_ptr)\n \t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n \t\treturn 0;\n \tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n \t\treturn EINVAL;\n \tdefault:\n+\t\t/* the wait failed, so do not detach */\n \t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n-- \ngitgitgadget\n"},{"id":"469807","messageId":"a20eafb954193fe5cd2bad2f65d86f6116339380.1672933474.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v14.git.git.1672933474.gitgitgadget@gmail.com","subject":"[PATCH v14 1/2] win32: prepare pthread.c for change by formatting","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-05T15:44:33Z","receivedAt":"2023-01-05T15:44:45Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nFile has been formatted to meet coding guidelines.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex 2e7eead42cb..cf53bc61d82 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg)\n }\n \n int pthread_create(pthread_t *thread, const void *unused,\n-\t\t   void *(*start_routine)(void*), void *arg)\n+\t\t   void *(*start_routine)(void *), void *arg)\n {\n \tthread->arg = arg;\n \tthread->start_routine = start_routine;\n-\tthread->handle = (HANDLE)\n-\t\t_beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL);\n+\tthread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine,\n+\t\t\t\t\t\tthread, 0, NULL);\n \n \tif (!thread->handle)\n \t\treturn errno;\n@@ -39,14 +39,14 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n {\n \tDWORD result = WaitForSingleObject(thread->handle, INFINITE);\n \tswitch (result) {\n-\t\tcase WAIT_OBJECT_0:\n-\t\t\tif (value_ptr)\n-\t\t\t\t*value_ptr = thread->arg;\n-\t\t\treturn 0;\n-\t\tcase WAIT_ABANDONED:\n-\t\t\treturn EINVAL;\n-\t\tdefault:\n-\t\t\treturn err_win_to_posix(GetLastError());\n+\tcase WAIT_OBJECT_0:\n+\t\tif (value_ptr)\n+\t\t\t*value_ptr = thread->arg;\n+\t\treturn 0;\n+\tcase WAIT_ABANDONED:\n+\t\treturn EINVAL;\n+\tdefault:\n+\t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n \n-- \ngitgitgadget\n\n"},{"id":"469808","messageId":"aa0319bc08e5b05f291fb2b1e9e1b20734f512bf.1672933474.git.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v14.git.git.1672933474.gitgitgadget@gmail.com","subject":"[PATCH v14 2/2] win32: close handles of threads that have been joined","fromName":"Seija Kijin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-05T15:44:34Z","receivedAt":"2023-01-05T15:44:50Z","isPatch":true,"sender":{"key":"name:Seija Kijin","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nAfter the thread terminates, the handle to the\noriginal thread should be closed.\n\nThis change makes win32_pthread_join POSIX compliant.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n compat/win32/pthread.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/compat/win32/pthread.c b/compat/win32/pthread.c\nindex cf53bc61d82..85f8f7920ce 100644\n--- a/compat/win32/pthread.c\n+++ b/compat/win32/pthread.c\n@@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)\n \tcase WAIT_OBJECT_0:\n \t\tif (value_ptr)\n \t\t\t*value_ptr = thread->arg;\n+\t\tCloseHandle(thread->handle);\n \t\treturn 0;\n \tcase WAIT_ABANDONED:\n+\t\tCloseHandle(thread->handle);\n \t\treturn EINVAL;\n \tdefault:\n+\t\t/* the wait failed, so do not detach */\n \t\treturn err_win_to_posix(GetLastError());\n \t}\n }\n-- \ngitgitgadget\n"},{"id":"469809","messageId":"pull.1406.v14.git.git.1672933474.gitgitgadget@gmail.com","threadId":"58983","inReplyTo":"pull.1406.v13.git.git.1672762819.gitgitgadget@gmail.com","subject":"[PATCH v14 0/2] win32: close handles of threads that have been joined","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-05T15:44:32Z","receivedAt":"2023-01-05T15:44:50Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"After joining threads, the handle to the original thread should be closed as\nit no longer needs to be open.\n\nSigned-off-by: Seija Kijin doremylover123@gmail.com\n\nSeija Kijin (2):\n  win32: prepare pthread.c for change by formatting\n  win32: close handles of threads that have been joined\n\n compat/win32/pthread.c | 25 ++++++++++++++-----------\n 1 file changed, 14 insertions(+), 11 deletions(-)\n\n\nbase-commit: 4dbebc36b0893f5094668ddea077d0e235560b16\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v14\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v14\nPull-Request: https://github.com/git/git/pull/1406\n\nRange-diff vs v13:\n\n 1:  6f89b120641 = 1:  a20eafb9541 win32: prepare pthread.c for change by formatting\n 2:  f126d6416d5 = 2:  aa0319bc08e win32: close handles of threads that have been joined\n\n-- \ngitgitgadget\n"},{"id":"469825","messageId":"xmqqzgavsv8v.fsf@gitster.g","threadId":"58983","inReplyTo":"pull.1406.v14.git.git.1672933474.gitgitgadget@gmail.com","subject":"Re: [PATCH v14 0/2] win32: close handles of threads that have been joined","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-01-06T12:28:00Z","receivedAt":"2023-01-06T12:28:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rose via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> After joining threads, the handle to the original thread should be closed as\n> it no longer needs to be open.\n>\n> Signed-off-by: Seija Kijin doremylover123@gmail.com\n>\n> Seija Kijin (2):\n>   win32: prepare pthread.c for change by formatting\n>   win32: close handles of threads that have been joined\n>\n>  compat/win32/pthread.c | 25 ++++++++++++++-----------\n>  1 file changed, 14 insertions(+), 11 deletions(-)\n>\n>\n> base-commit: 4dbebc36b0893f5094668ddea077d0e235560b16\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1406%2FAtariDreams%2Fjoin-v14\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1406/AtariDreams/join-v14\n> Pull-Request: https://github.com/git/git/pull/1406\n>\n> Range-diff vs v13:\n>\n>  1:  6f89b120641 = 1:  a20eafb9541 win32: prepare pthread.c for change by formatting\n>  2:  f126d6416d5 = 2:  aa0319bc08e win32: close handles of threads that have been joined\n\n\nIn general, the cover letter of a reroll should explain why\nreviewers are asked to look at the updated version instead of the\nolder one, i.e. what changed since the previous iteration and why.\nFor those who followed and/or participated in the review of previous\niterations, the range-diff might be sufficient to guess why these\nchanges were made in order to improve what, but for those who are\ncoming late to the party, it would be helpful if you explain what\nyou changed, how and why.\n\nThis is true especially if (1) you are rerolling even though the\nprevious round got little reviews or (2) you are resending without\nany change.\n\nThanks.\n\n"}]}