gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (55e6a9e2 -> e07c332c)


From: gnunet
Subject: [libmicrohttpd] branch master updated (55e6a9e2 -> e07c332c)
Date: Mon, 15 Mar 2021 14:37:57 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 55e6a9e2 fix typo
     new 4c0247d4 MHD_start_daemon(): do not use log before user settings are 
processed
     new 1717035d daemon: added user options counter
     new e07c332c MHD_start_daemon(): warn if messages could be printed by 
wrong logger

The 3 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/include/microhttpd.h  |  2 ++
 src/microhttpd/daemon.c   | 30 +++++++++++++++++++++++-------
 src/microhttpd/internal.h |  9 +++++++++
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 1d44f344..900bfd72 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -1520,6 +1520,8 @@ enum MHD_OPTION
    * a function of type #MHD_LogCallback and the second a pointer
    * `void *` which will be passed as the first argument to the log
    * callback.
+   * Should be specified as the first option, otherwise some messages
+   * may be printed by standard MHD logger during daemon startup.
    *
    * Note that MHD will not generate any log messages
    * if it was compiled without the "--enable-messages"
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index bcf1a014..535d85aa 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -5403,6 +5403,9 @@ parse_options_va (struct MHD_Daemon *daemon,
 
   while (MHD_OPTION_END != (opt = (enum MHD_OPTION) va_arg (ap, int)))
   {
+    /* Increase counter at start, so resulting value is number of
+     * processed options, including any failed ones. */
+    daemon->num_opts++;
     switch (opt)
     {
     case MHD_OPTION_CONNECTION_MEMORY_LIMIT:
@@ -5738,6 +5741,12 @@ parse_options_va (struct MHD_Daemon *daemon,
                                          VfprintfFunctionPointerType);
       daemon->custom_error_log_cls = va_arg (ap,
                                              void *);
+      if (1 != daemon->num_opts)
+        MHD_DLOG (daemon,
+                  _ ("MHD_OPTION_EXTERNAL_LOGGER is not the first option "
+                     "specified for the daemon. Some messages may be "
+                     "printed by the standard MHD logger.\n"));
+
 #else
       va_arg (ap,
               VfprintfFunctionPointerType);
@@ -5784,6 +5793,7 @@ parse_options_va (struct MHD_Daemon *daemon,
 #endif /* HAVE_MESSAGES */
       break;
     case MHD_OPTION_ARRAY:
+      daemon->num_opts--; /* Do not count MHD_OPTION_ARRAY */
       oa = va_arg (ap, struct MHD_OptionItem*);
       i = 0;
       while (MHD_OPTION_END != (opt = oa[i].option))
@@ -6236,13 +6246,7 @@ MHD_start_daemon_va (unsigned int flags,
   if ( (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) &&
        (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) )
   {
-#ifdef HAVE_MESSAGES
-    MHD_DLOG (daemon,
-              _ (
-                "Warning: MHD_USE_THREAD_PER_CONNECTION must be used only with 
"
-                "MHD_USE_INTERNAL_POLLING_THREAD. Flag 
MHD_USE_INTERNAL_POLLING_THREAD "
-                "was added. Consider setting MHD_USE_INTERNAL_POLLING_THREAD 
explicitly.\n"));
-#endif
+    /* Log warning message later, when log parameters are processes */
     *pflags |= MHD_USE_INTERNAL_POLLING_THREAD;
   }
   if (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD))
@@ -6280,6 +6284,18 @@ MHD_start_daemon_va (unsigned int flags,
     return NULL;
   }
 
+#ifdef HAVE_MESSAGES
+  if ( (0 != (flags & MHD_USE_THREAD_PER_CONNECTION)) &&
+       (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD)) )
+  {
+    MHD_DLOG (daemon,
+              _ (
+                "Warning: MHD_USE_THREAD_PER_CONNECTION must be used only with 
"
+                "MHD_USE_INTERNAL_POLLING_THREAD. Flag 
MHD_USE_INTERNAL_POLLING_THREAD "
+                "was added. Consider setting MHD_USE_INTERNAL_POLLING_THREAD 
explicitly.\n"));
+  }
+#endif
+
   if ( (NULL != daemon->notify_completed) &&
        (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) )
     *pflags |= MHD_USE_ITC; /* requires ITC */
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 06e7e4a7..dc38bada 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1920,6 +1920,15 @@ struct MHD_Daemon
    * The size of queue for listen socket.
    */
   unsigned int listen_backlog_size;
+
+  /**
+   * The number of user options used.
+   *
+   * Contains number of only meaningful options, i.e. #MHD_OPTION_END
+   * and #MHD_OPTION_ARRAY are not counted, while options inside
+   * #MHD_OPTION_ARRAY are counted.
+   */
+  size_t num_opts;
 };
 
 

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