gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 03/05: MHD_set_connection_option(): reduced lock scope


From: gnunet
Subject: [libmicrohttpd] 03/05: MHD_set_connection_option(): reduced lock scope
Date: Thu, 12 May 2022 15:42:21 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 2590e0e8913bdf8cfa19113cb42d9738413c9d70
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu May 12 15:47:50 2022 +0300

    MHD_set_connection_option(): reduced lock scope
    
    Improved handling of setting the new connection timeout. Log function
    is not called with lock held. Simplified logic, completely avoided
    locking in thread-per-connection mode
---
 src/microhttpd/connection.c | 57 +++++++++++++++++++++------------------------
 1 file changed, 27 insertions(+), 30 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 93408eb7..4ca35e0d 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -5107,21 +5107,6 @@ MHD_set_connection_option (struct MHD_Connection 
*connection,
   case MHD_CONNECTION_OPTION_TIMEOUT:
     if (0 == connection->connection_timeout_ms)
       connection->last_activity = MHD_monotonic_msec_counter ();
-#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
-    MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-#endif
-    if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-         (! connection->suspended) )
-    {
-      if (connection->connection_timeout_ms == daemon->connection_timeout_ms)
-        XDLL_remove (daemon->normal_timeout_head,
-                     daemon->normal_timeout_tail,
-                     connection);
-      else
-        XDLL_remove (daemon->manual_timeout_head,
-                     daemon->manual_timeout_tail,
-                     connection);
-    }
     va_start (ap, option);
     ui_val = va_arg (ap, unsigned int);
     va_end (ap);
@@ -5138,24 +5123,36 @@ MHD_set_connection_option (struct MHD_Connection 
*connection,
 #endif
       ui_val = UINT64_MAX / 4000 - 1;
     }
-    else
 #endif /* (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT */
-    connection->connection_timeout_ms = ui_val * 1000;
-    if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-         (! connection->suspended) )
+    if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
-      if (connection->connection_timeout_ms == daemon->connection_timeout_ms)
-        XDLL_insert (daemon->normal_timeout_head,
-                     daemon->normal_timeout_tail,
-                     connection);
-      else
-        XDLL_insert (daemon->manual_timeout_head,
-                     daemon->manual_timeout_tail,
-                     connection);
-    }
-#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
-    MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#if defined(MHD_USE_THREADS)
+      MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
 #endif
+      if (! connection->suspended)
+      {
+        if (connection->connection_timeout_ms == daemon->connection_timeout_ms)
+          XDLL_remove (daemon->normal_timeout_head,
+                       daemon->normal_timeout_tail,
+                       connection);
+        else
+          XDLL_remove (daemon->manual_timeout_head,
+                       daemon->manual_timeout_tail,
+                       connection);
+        connection->connection_timeout_ms = ui_val * 1000;
+        if (connection->connection_timeout_ms == daemon->connection_timeout_ms)
+          XDLL_insert (daemon->normal_timeout_head,
+                       daemon->normal_timeout_tail,
+                       connection);
+        else
+          XDLL_insert (daemon->manual_timeout_head,
+                       daemon->manual_timeout_tail,
+                       connection);
+      }
+#if defined(MHD_USE_THREADS)
+      MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
+    }
     return MHD_YES;
   default:
     return MHD_NO;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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