gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 110/156: digest auth: fixed parallel access to the hash


From: gnunet
Subject: [libmicrohttpd] 110/156: digest auth: fixed parallel access to the hash table
Date: Sun, 28 May 2023 17:52:43 +0200

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

karlson2k pushed a commit to tag v0.9.77
in repository libmicrohttpd.

commit a9903c25d639d97ad93d524eeeab8dd3eb377bdf
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu May 18 16:52:46 2023 +0300

    digest auth: fixed parallel access to the hash table
---
 src/microhttpd/daemon.c     | 6 +++++-
 src/microhttpd/digestauth.c | 2 +-
 src/microhttpd/internal.h   | 9 +++++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index b9192406..3801e438 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -257,7 +257,7 @@ MHD_free (void *ptr)
  * @param daemon handle to a daemon
  * @return master daemon handle
  */
-static struct MHD_Daemon *
+struct MHD_Daemon *
 MHD_get_master (struct MHD_Daemon *daemon)
 {
   while (NULL != daemon->master)
@@ -7277,6 +7277,10 @@ MHD_start_daemon_va (unsigned int flags,
         d->master = daemon;
         d->worker_pool_size = 0;
         d->worker_pool = NULL;
+#if defined(DAUTH_SUPPORT) && defined(MHD_USE_THREADS)
+        /* Avoid accidental re-use of the mutex copies */
+        memset (&d->nnc_lock, -1, sizeof(d->nnc_lock));
+#endif /* DAUTH_SUPPORT && MHD_USE_THREADS */
         if (! MHD_mutex_init_ (&d->new_connections_mutex))
         {
   #ifdef HAVE_MESSAGES
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index dd8ea81d..360fa0e4 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -529,7 +529,7 @@ check_nonce_nc (struct MHD_Connection *connection,
                 const char *nonce,
                 uint64_t nc)
 {
-  struct MHD_Daemon *daemon = connection->daemon;
+  struct MHD_Daemon *const daemon = MHD_get_master (connection->daemon);
   struct MHD_NonceNc *nn;
   uint32_t off;
   uint32_t mod;
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index f5c965ec..cf51a5e0 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -2395,6 +2395,15 @@ MHD_check_response_header_token_ci (const struct 
MHD_Response *response,
   MHD_check_response_header_token_ci ((r),(k),MHD_STATICSTR_LEN_ (k), \
                                       (tkn),MHD_STATICSTR_LEN_ (tkn))
 
+/**
+ * Trace up to and return master daemon. If the supplied daemon
+ * is a master, then return the daemon itself.
+ *
+ * @param daemon handle to a daemon
+ * @return master daemon handle
+ */
+struct MHD_Daemon *
+MHD_get_master (struct MHD_Daemon *daemon);
 
 /**
  * Internal version of #MHD_suspend_connection().

-- 
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]