commit d8bf6d3c9946afb3299fd6ac896a5fe494623746
parent 82e360f0f12c05fb09555fade6ddaaffe8a739fc
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Fri, 26 Dec 2014 13:28:05 +0000
[W32] Use _beginthreadex() instead of CreateThread() for better compatibility with CRT functions called in additional threads
Diffstat:
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/include/platform_interface.h b/src/include/platform_interface.h
@@ -202,8 +202,8 @@ typedef HANDLE MHD_thread_handle_;
#define MHD_THRD_RTRN_TYPE_ void*
#define MHD_THRD_CALL_SPEC_
#elif defined(MHD_USE_W32_THREADS)
-#define MHD_THRD_RTRN_TYPE_ DWORD
-#define MHD_THRD_CALL_SPEC_ WINAPI
+#define MHD_THRD_RTRN_TYPE_ unsigned
+#define MHD_THRD_CALL_SPEC_ __stdcall
#endif
#if defined(MHD_USE_POSIX_THREADS)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -63,6 +63,7 @@
#define WIN32_LEAN_AND_MEAN 1
#endif /* !WIN32_LEAN_AND_MEAN */
#include <windows.h>
+#include <process.h>
#endif
#ifndef HAVE_ACCEPT4
@@ -1110,11 +1111,11 @@ create_thread (MHD_thread_handle_ *thread,
errno = EINVAL;
return ret;
#elif defined(MHD_USE_W32_THREADS)
- DWORD threadID;
- *thread = CreateThread(NULL, daemon->thread_stack_size, start_routine,
+ unsigned threadID;
+ *thread = (HANDLE)_beginthreadex(NULL, (unsigned)daemon->thread_stack_size, start_routine,
arg, 0, &threadID);
if (NULL == (*thread))
- return EINVAL;
+ return errno;
W32_SetThreadName(threadID, "libmicrohttpd");