gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] 03/03: Thread-safety: always lock mutex whe


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 03/03: Thread-safety: always lock mutex when modifying "cleanup" or "timeout" DL-lists
Date: Thu, 16 Mar 2017 18:47:13 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 88374e04d2339297e75a34a798611bfb92225c4b
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Thu Mar 16 20:37:57 2017 +0300

    Thread-safety: always lock mutex when modifying "cleanup" or "timeout" 
DL-lists
---
 ChangeLog                   | 7 +++++++
 src/microhttpd/connection.c | 2 ++
 src/microhttpd/daemon.c     | 5 +++++
 src/microhttpd/internal.h   | 3 ++-
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 7cca315c..882c9598 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Mar 16 20:35:59 MSK 2017
+       Improved thread-safety for DL-lists. -EG
+
+Thu Mar 16 17:55:01 MSK 2017
+       Fixed thread-safety of MHD_get_daemon_info() for
+       MHD_DAEMON_INFO_CURRENT_CONNECTIONS. -EG
+
 Thu Mar 16 16:49:07 MSK 2017
        Added ability to get actual daemon flags via MHD_get_daemon_info().
        Fixed test_upgrade to work in request mode.
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 74238a1b..7740e0e7 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2382,6 +2382,7 @@ update_last_activity (struct MHD_Connection *connection)
   if (connection->connection_timeout != daemon->connection_timeout)
     return; /* custom timeout, no need to move it in "normal" DLL */
 
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
   /* move connection to head of timeout list (by remove + add operation) */
   XDLL_remove (daemon->normal_timeout_head,
               daemon->normal_timeout_tail,
@@ -2389,6 +2390,7 @@ update_last_activity (struct MHD_Connection *connection)
   XDLL_insert (daemon->normal_timeout_head,
               daemon->normal_timeout_tail,
               connection);
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 }
 
 
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 001c3586..d3b02c27 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4403,6 +4403,9 @@ close_connection (struct MHD_Connection *pos)
     }
   MHD_connection_close_ (pos,
                          MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN);
+
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+
   if (pos->connection_timeout == pos->daemon->connection_timeout)
     XDLL_remove (daemon->normal_timeout_head,
                 daemon->normal_timeout_tail,
@@ -4417,6 +4420,8 @@ close_connection (struct MHD_Connection *pos)
   DLL_insert (daemon->cleanup_head,
              daemon->cleanup_tail,
              pos);
+
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 }
 
 
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index f9172372..44590878 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1373,7 +1373,8 @@ struct MHD_Daemon
   MHD_mutex_ per_ip_connection_mutex;
 
   /**
-   * Mutex for (modifying) access to the "cleanup" connection DLL.
+   * Mutex for (modifying) access to the "cleanup", "normal_timeout" and
+   * "manual_timeout" DLLs.
    */
   MHD_mutex_ cleanup_connection_mutex;
 

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



reply via email to

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