gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (8a84902f -> ba9f1fc8


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (8a84902f -> ba9f1fc8)
Date: Tue, 14 Feb 2017 18:06:06 +0100

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

grothoff pushed a change to branch master
in repository libmicrohttpd.

    from 8a84902f mark 'was_closed' as volatile; move connection resumption to 
end of upgrade routine to avoid race issue; eliminate dead code
     new 3ba8a0c8 convert 'thread_joined' to bool
     new ba9f1fc8 eliminate non-trival cleanup race (rare, only for 
thread-per-connection)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/microhttpd/daemon.c             | 14 ++++++++------
 src/microhttpd/internal.h           |  4 ++--
 src/testcurl/https/test_https_get.c |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index fda7f51b..bc26b53f 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2788,7 +2788,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
       MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 
       if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-          (MHD_NO == pos->thread_joined) &&
+          (! pos->thread_joined) &&
            (! MHD_join_thread_ (pos->pid)) )
         MHD_PANIC (_("Failed to join a thread\n"));
 #ifdef UPGRADE_SUPPORT
@@ -5552,7 +5552,7 @@ thread_failed:
 
 /**
  * Close all connections for the daemon.
- * Must only be called when MHD_Daemon::shutdown was set to #MHD_YES.
+ * Must only be called when MHD_Daemon::shutdown was set to true.
  * @remark To be called only from thread that process
  * daemon's select()/poll()/etc.
  *
@@ -5650,7 +5650,6 @@ close_all_connections (struct MHD_Daemon *daemon)
         MHD_PANIC (_("Failed to signal shutdown via inter-thread communication 
channel"));
 #endif
     }
-  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 
   /* now, collect per-connection threads */
   if (used_thr_p_c)
@@ -5658,11 +5657,13 @@ close_all_connections (struct MHD_Daemon *daemon)
       pos = daemon->connections_head;
       while (NULL != pos)
       {
-        if (MHD_YES != pos->thread_joined)
+        if (! pos->thread_joined)
           {
+            MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
             if (! MHD_join_thread_ (pos->pid))
               MHD_PANIC (_("Failed to join a thread\n"));
-            pos->thread_joined = MHD_YES;
+            MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+            pos->thread_joined = true;
             /* The thread may have concurrently modified the DLL,
                need to restart from the beginning */
             pos = daemon->connections_head;
@@ -5671,6 +5672,7 @@ close_all_connections (struct MHD_Daemon *daemon)
         pos = pos->next;
       }
     }
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 
 #ifdef UPGRADE_SUPPORT
   /* Finished threads with "upgraded" connections need to be moved
@@ -5688,7 +5690,7 @@ close_all_connections (struct MHD_Daemon *daemon)
   while (NULL != (pos = daemon->connections_head))
   {
     if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-         (MHD_YES != pos->thread_joined) )
+         (! pos->thread_joined) )
       MHD_PANIC (_("Failed to join a thread\n"));
     close_connection (pos);
   }
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 5acc21d9..a562454e 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -811,9 +811,9 @@ struct MHD_Connection
   int read_closed;
 
   /**
-   * Set to #MHD_YES if the thread has been joined.
+   * Set to `true` if the thread has been joined.
    */
-  int thread_joined;
+  bool thread_joined;
 
   /**
    * Are we currently inside the "idle" handler (to avoid recursively
diff --git a/src/testcurl/https/test_https_get.c 
b/src/testcurl/https/test_https_get.c
index f5b47e65..f8795b9b 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -43,9 +43,9 @@ test_cipher_option (FILE * test_fd,
                    const char *cipher_suite,
                    int proto_version)
 {
-
   int ret;
   struct MHD_Daemon *d;
+
   d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | 
MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS |
                         MHD_USE_ERROR_LOG, 4233,
                         NULL, NULL, &http_ahc, NULL,

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



reply via email to

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