[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 02/02: eliminate non-trival cleanup race (r
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 02/02: eliminate non-trival cleanup race (rare, only for thread-per-connection) |
Date: |
Tue, 14 Feb 2017 18:06:08 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository libmicrohttpd.
commit ba9f1fc809a2de1444e07104f234c89acac55c0d
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue Feb 14 18:06:59 2017 +0100
eliminate non-trival cleanup race (rare, only for thread-per-connection)
---
src/microhttpd/daemon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 5ac7c341..bc26b53f 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -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)
@@ -5660,8 +5659,10 @@ close_all_connections (struct MHD_Daemon *daemon)
{
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"));
+ 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 */
@@ -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
--
To stop receiving notification emails like this one, please contact
address@hidden