Skip to content

Commit 0006e2e

Browse files
Seija Kijingitster
authored andcommitted
win32: use _endthreadex to terminate threads, not ExitThread
Because we use the C runtime and use _beginthreadex to create pthreads, pthread_exit MUST use _endthreadex. Otherwise, according to Microsoft: "Failure to do so results in small memory leaks when the thread calls ExitThread." Simply put, this is not the same as ExitThread. Signed-off-by: Seija Kijin <[email protected]> Acked-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c2ef31 commit 0006e2e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compat/win32/pthread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pthread_t pthread_self(void);
6666

6767
static inline void NORETURN pthread_exit(void *ret)
6868
{
69-
ExitThread((DWORD)(intptr_t)ret);
69+
_endthreadex((unsigned)(uintptr_t)ret);
7070
}
7171

7272
typedef DWORD pthread_key_t;

0 commit comments

Comments
 (0)