libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 1ce136022b6e9306fe19886424f10c1812a8fe3d
parent 92bf38a98de945e4a18e8d53d96f9d473a342e7e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Wed, 15 Nov 2017 15:32:12 +0300

Fixed race condition on W32

Diffstat:
Msrc/microhttpd/daemon.c | 2++
Msrc/microhttpd/mhd_threads.c | 2+-
Msrc/microhttpd/mhd_threads.h | 14++++++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -1715,6 +1715,7 @@ thread_main_handle_connection (void *data) const bool use_poll = 0; #endif /* ! HAVE_POLL */ bool was_suspended = false; + MHD_thread_init_(&(con->pid)); while ( (! daemon->shutdown) && (MHD_CONNECTION_CLOSED != con->state) ) @@ -4370,6 +4371,7 @@ static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ MHD_polling_thread (void *cls) { struct MHD_Daemon *daemon = cls; + MHD_thread_init_(&(daemon->pid)); while (! daemon->shutdown) { diff --git a/src/microhttpd/mhd_threads.c b/src/microhttpd/mhd_threads.c @@ -224,7 +224,7 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread, start_routine, arg, 0, - (unsigned*)&thread->ID); + NULL); if ((MHD_thread_handle_)-1 == thread->handle) return 0; diff --git a/src/microhttpd/mhd_threads.h b/src/microhttpd/mhd_threads.h @@ -139,6 +139,20 @@ #define MHD_thread_ID_match_current_(ID) (GetCurrentThreadId() == (ID)) #endif +#if defined(MHD_USE_POSIX_THREADS) +/** + * Initialise thread ID. + * @param thread_handle_ID_ptr pointer to thread handle-ID + */ +#define MHD_thread_init_(thread_handle_ID_ptr) (void)0 +#elif defined(MHD_USE_W32_THREADS) +/** + * Initialise thread ID. + * @param thread_handle_ID_ptr pointer to thread handle-ID + */ +#define MHD_thread_init_(thread_handle_ID_ptr) ((thread_handle_ID_ptr)->ID=GetCurrentThreadId()) +#endif + /** * Signature of main function for a thread. *