gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] 01/04: Fixed race condition on W32


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 01/04: Fixed race condition on W32
Date: Wed, 15 Nov 2017 14:17:14 +0100

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 1ce136022b6e9306fe19886424f10c1812a8fe3d
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Wed Nov 15 15:32:12 2017 +0300

    Fixed race condition on W32
---
 src/microhttpd/daemon.c      |  2 ++
 src/microhttpd/mhd_threads.c |  2 +-
 src/microhttpd/mhd_threads.h | 14 ++++++++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 62f5b094..8ead8610 100644
--- 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
index 21d0ecc7..6578e4b1 100644
--- 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
index d5424659..1a06c64a 100644
--- 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.
  *

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]