]> git.ipfire.org Git - thirdparty/curl.git/commit
windows: replace `_beginthreadex()` with `CreateThread()`
authorViktor Szakats <commit@vsz.me>
Fri, 1 Aug 2025 19:09:52 +0000 (21:09 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 19 Sep 2025 23:28:35 +0000 (01:28 +0200)
commit1c49f2f26d0f200bb9de61f795f06a1bc56845e9
treeded8591c37e5d64217a5dfa233f01ae8c42ef7f6
parent8d004781a577fc2fae72873c4a45b2fb3f366d98
windows: replace `_beginthreadex()` with `CreateThread()`

Replace `_beginthreadex()` C runtime calls with native win32 API
`CreateThread()`. The latter was already used in `src/tool_doswin.c`
and in UWP and Windows CE builds before this patch. After this patch
all Windows flavors use it. To drop PP logic and simplify code.

While working on this it turned out that `src/tool_doswin.c` calls
`TerminateThread()`, which isn't recommended by the documentation,
except for "the most extreme cases". This patch makes no attempt
to change that code.
Ref: 9a2663322c330ff11275abafd612e9c99407a94a #17572
Ref: https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread

Also:
- use `WaitForSingleObjectEx()` on all desktop Windows.
  Ref: 4be80d5109a340973dc6ce0221ec5c5761587df0
  Ref: https://sourceforge.net/p/curl/feature-requests/82/
  Ref: https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-waitforsingleobjectex
- tests: drop redundant casts.
- lib3207: fix to not rely on thread macros when building without thread
  support.

Assisted-by: Jay Satiro
Assisted-by: Marcel Raad
Assisted-by: MichaƂ Petryka
Follow-up to 38029101e2d78ba125732b3bab6ec267b80a0e72 #11625

Closes #18451
lib/curl_threads.c
lib/curl_threads.h
tests/libtest/lib3026.c
tests/libtest/lib3207.c
tests/server/sockfilt.c
tests/server/util.c