gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (11fc9224 -> 6f6a4e22


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (11fc9224 -> 6f6a4e22)
Date: Sun, 26 Mar 2017 12:52:38 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 11fc9224 remove dead code converting hex number to size_t
     new ad75fbc0 MHD_start_daemon_va(): unify 'flags' and 'daemon->options' 
usage
     new ab04f53b Simplified checks for allowed suspend, fixed false positive 
for daemons with MHD_USE_ITC
     new b5bfa6ee Simplification: move external loop specific code from 
internal_run_from_select() to  MHD_run_from_select().
     new 8cdcc780 Streamlined internal usage of MHD_USE_ITC flag.
     new c14c7bb6 MHD_select(): Removed bogus extra check
     new 7b0d9290 MHD_start_daemon(): removed initialisation of ITC for master 
daemon in thread pool mode as global ITC is not monitored. Fixed gnutls 
priorities deinitialization if ITC failed
     new 6f6a4e22 MHD_start_daemon(): obey MHD_USE_ITC in thread pool mode

The 7 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:
 ChangeLog                 |   5 ++
 src/microhttpd/daemon.c   | 220 ++++++++++++++++++++++++----------------------
 src/microhttpd/internal.h |   6 ++
 3 files changed, 124 insertions(+), 107 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4f627234..147a1741 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Mar 26 13:49:01 MSK 2017
+       Internal refactoring for simplification and unification.
+       Minor optimizations and minor fixes.
+       MHD_USE_ITC used again in thread pool mode. -EG
+
 Sat Mar 25 20:58:24 CET 2017
        Remove dead MHD_strx_to_sizet-functions and associated
        test cases from code. -CG
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f2427902..bda9292f 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2728,7 +2728,7 @@ MHD_suspend_connection (struct MHD_Connection *connection)
 {
   struct MHD_Daemon *daemon = connection->daemon;
 
-  if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME))
+  if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
     MHD_PANIC (_("Cannot suspend connections without enabling 
MHD_ALLOW_SUSPEND_RESUME!\n"));
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
   if (connection->resuming)
@@ -2797,7 +2797,7 @@ MHD_resume_connection (struct MHD_Connection *connection)
   struct MHD_Daemon *daemon;
 
   daemon = connection->daemon;
-  if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME))
+  if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
     MHD_PANIC (_("Cannot resume connections without enabling 
MHD_ALLOW_SUSPEND_RESUME!\n"));
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
   connection->resuming = true;
@@ -3332,9 +3332,6 @@ internal_run_from_select (struct MHD_Daemon *daemon,
   struct MHD_UpgradeResponseHandle *urh;
   struct MHD_UpgradeResponseHandle *urhn;
 #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
-  unsigned int mask = MHD_ALLOW_SUSPEND_RESUME | MHD_USE_EPOLL_INTERNAL_THREAD 
|
-    MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_POLL_INTERNAL_THREAD;
-
   /* Reset. New value will be set when connections are processed. */
   /* Note: no-op for thread-per-connection as it is always false in that mode. 
*/
   daemon->data_already_pending = false;
@@ -3347,10 +3344,6 @@ internal_run_from_select (struct MHD_Daemon *daemon,
                   read_fd_set)) )
     MHD_itc_clear_ (daemon->itc);
 
-  /* Resuming external connections when using an extern mainloop  */
-  if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & mask))
-    resume_suspended_connections (daemon);
-
 #ifdef EPOLL_SUPPORT
   if (0 != (daemon->options & MHD_USE_EPOLL))
     {
@@ -3478,6 +3471,10 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
       return MHD_NO;
 #endif /* ! EPOLL_SUPPORT */
     }
+
+  /* Resuming external connections when using an extern mainloop  */
+  resume_suspended_connections (daemon);
+
   return internal_run_from_select (daemon, read_fd_set,
                                    write_fd_set, except_fd_set);
 }
@@ -3517,7 +3514,7 @@ MHD_select (struct MHD_Daemon *daemon,
   err_state = MHD_NO;
   if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
-      if ( (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & 
MHD_ALLOW_SUSPEND_RESUME)) &&
+      if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) &&
            (MHD_YES == resume_suspended_connections (daemon)) )
         may_block = MHD_NO;
 
@@ -3593,7 +3590,6 @@ MHD_select (struct MHD_Daemon *daemon,
      place. */
   if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) &&
        (MHD_ITC_IS_VALID_(daemon->itc)) &&
-       (0 != (daemon->options & MHD_USE_ITC)) &&
        ( (daemon->connections == daemon->connection_limit) ||
          (daemon->at_limit) ) )
     {
@@ -3669,7 +3665,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
   struct MHD_UpgradeResponseHandle *urhn;
 #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
 
-  if ( (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & 
MHD_ALLOW_SUSPEND_RESUME)) &&
+  if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) &&
        (MHD_YES == resume_suspended_connections (daemon)) )
     may_block = MHD_NO;
 
@@ -4375,7 +4371,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
 
   /* we handle resumes here because we may have ready connections
      that will not be placed into the epoll list immediately. */
-  if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & MHD_ALLOW_SUSPEND_RESUME))
+  if (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
     (void) resume_suspended_connections (daemon);
 
   /* process events for connections */
@@ -5316,32 +5312,35 @@ MHD_start_daemon_va (unsigned int flags,
   const struct sockaddr *servaddr = NULL;
   socklen_t addrlen;
   unsigned int i;
-  int use_itc;
+  enum MHD_FLAG eflags; /* same type as in MHD_Daemon */
+  enum MHD_FLAG *pflags;
 
+  eflags = (enum MHD_FLAG) flags;
+  pflags = &eflags;
 #ifndef HAVE_INET6
-  if (0 != (flags & MHD_USE_IPv6))
+  if (0 != (*pflags & MHD_USE_IPv6))
     return NULL;
 #endif
 #ifndef HAVE_POLL
-  if (0 != (flags & MHD_USE_POLL))
+  if (0 != (*pflags & MHD_USE_POLL))
     return NULL;
 #endif
 #ifndef EPOLL_SUPPORT
-  if (0 != (flags & MHD_USE_EPOLL))
+  if (0 != (*pflags & MHD_USE_EPOLL))
     return NULL;
 #endif /* ! EPOLL_SUPPORT */
 #ifndef HTTPS_SUPPORT
-  if (0 != (flags & MHD_USE_TLS))
+  if (0 != (*pflags & MHD_USE_TLS))
     return NULL;
 #endif /* ! HTTPS_SUPPORT */
 #ifndef TCP_FASTOPEN
-  if (0 != (flags & MHD_USE_TCP_FASTOPEN))
+  if (0 != (*pflags & MHD_USE_TCP_FASTOPEN))
     return NULL;
 #endif
-  if (0 != (flags & MHD_ALLOW_UPGRADE))
+  if (0 != (*pflags & MHD_ALLOW_UPGRADE))
     {
 #ifdef UPGRADE_SUPPORT
-      flags |= MHD_ALLOW_SUSPEND_RESUME;
+      *pflags |= MHD_ALLOW_SUSPEND_RESUME;
 #else  /* ! UPGRADE_SUPPORT */
       return NULL;
 #endif /* ! UPGRADE_SUPPORT */
@@ -5350,30 +5349,30 @@ MHD_start_daemon_va (unsigned int flags,
     return NULL;
 
   /* Check for invalid combinations of flags. */
-  if ( ((0 != (flags & MHD_USE_POLL)) && (0 != (flags & MHD_USE_EPOLL))) ||
-       ((0 != (flags & MHD_USE_EPOLL)) && (0 != (flags & 
MHD_USE_THREAD_PER_CONNECTION))) ||
-       ((0 != (flags & MHD_USE_POLL)) && (0 == (flags & 
MHD_USE_INTERNAL_POLLING_THREAD))) ||
-       ((0 != (flags & MHD_USE_AUTO)) && (0 != (flags & (MHD_USE_POLL | 
MHD_USE_EPOLL)))) )
+  if ( ((0 != (*pflags & MHD_USE_POLL)) && (0 != (*pflags & MHD_USE_EPOLL))) ||
+       ((0 != (*pflags & MHD_USE_EPOLL)) && (0 != (*pflags & 
MHD_USE_THREAD_PER_CONNECTION))) ||
+       ((0 != (*pflags & MHD_USE_POLL)) && (0 == (*pflags & 
MHD_USE_INTERNAL_POLLING_THREAD))) ||
+       ((0 != (*pflags & MHD_USE_AUTO)) && (0 != (*pflags & (MHD_USE_POLL | 
MHD_USE_EPOLL)))) )
     return NULL;
 
-  if (0 != (flags & MHD_USE_AUTO))
+  if (0 != (*pflags & MHD_USE_AUTO))
     {
-      if (0 != (flags & MHD_USE_THREAD_PER_CONNECTION))
+      if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))
         {
           /* Thread per connection with internal polling thread. */
 #ifdef HAVE_POLL
-          flags |= MHD_USE_POLL;
+          *pflags |= MHD_USE_POLL;
 #else  /* ! HAVE_POLL */
           /* use select() - do not modify flags */
 #endif /* ! HAVE_POLL */
         }
-      else if (0 != (flags & MHD_USE_INTERNAL_POLLING_THREAD))
+      else if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD))
         {
           /* Internal polling thread. */
 #if defined(EPOLL_SUPPORT)
-          flags |= MHD_USE_EPOLL;
+          *pflags |= MHD_USE_EPOLL;
 #elif defined(HAVE_POLL)
-          flags |= MHD_USE_POLL;
+          *pflags |= MHD_USE_POLL;
 #else  /* !HAVE_POLL && !EPOLL_SUPPORT */
           /* use select() - do not modify flags */
 #endif /* !HAVE_POLL && !EPOLL_SUPPORT */
@@ -5382,7 +5381,7 @@ MHD_start_daemon_va (unsigned int flags,
         {
           /* Internal threads are not used - "external" polling mode. */
 #if defined(EPOLL_SUPPORT)
-          flags |= MHD_USE_EPOLL;
+          *pflags |= MHD_USE_EPOLL;
 #else  /* ! EPOLL_SUPPORT */
           /* use select() - do not modify flags */
 #endif /* ! EPOLL_SUPPORT */
@@ -5399,7 +5398,8 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
   /* try to open listen socket */
 #ifdef HTTPS_SUPPORT
-  if (0 != (flags & MHD_USE_TLS))
+  daemon->priority_cache = NULL;
+  if (0 != (*pflags & MHD_USE_TLS))
     {
       gnutls_priority_init (&daemon->priority_cache,
                            "NORMAL",
@@ -5408,7 +5408,8 @@ MHD_start_daemon_va (unsigned int flags,
 #endif /* HTTPS_SUPPORT */
   daemon->listen_fd = MHD_INVALID_SOCKET;
   daemon->listening_address_reuse = 0;
-  daemon->options = flags;
+  daemon->options = *pflags;
+  pflags = &daemon->options;
   daemon->port = port;
   daemon->apc = apc;
   daemon->apc_cls = apc_cls;
@@ -5430,8 +5431,8 @@ MHD_start_daemon_va (unsigned int flags,
   daemon->custom_error_log = (MHD_LogCallback) &vfprintf;
   daemon->custom_error_log_cls = stderr;
 #endif
-  if ( (0 != (flags & MHD_USE_THREAD_PER_CONNECTION)) &&
-       (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD)) )
+  if ( (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) &&
+       (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) )
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
@@ -5439,41 +5440,16 @@ MHD_start_daemon_va (unsigned int flags,
                   "MHD_USE_INTERNAL_POLLING_THREAD. Flag 
MHD_USE_INTERNAL_POLLING_THREAD "
                    "was added. Consider setting 
MHD_USE_INTERNAL_POLLING_THREAD explicitly.\n"));
 #endif
-      flags |= MHD_USE_INTERNAL_POLLING_THREAD;
-      daemon->options |= MHD_USE_INTERNAL_POLLING_THREAD;
+      *pflags |= MHD_USE_INTERNAL_POLLING_THREAD;
     }
-#ifdef HAVE_LISTEN_SHUTDOWN
-  use_itc = (0 != (daemon->options & (MHD_USE_NO_LISTEN_SOCKET | 
MHD_USE_ITC)));
-#else
-  use_itc = 1; /* yes, must use ITC to signal thread */
-#endif
-  if (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD))
-    use_itc = 0; /* useless if we are using 'external' select */
-  if (use_itc)
-  {
-    if (! MHD_itc_init_ (daemon->itc))
-    {
-#ifdef HAVE_MESSAGES
-      MHD_DLOG (daemon,
-               _("Failed to create inter-thread communication channel: %s\n"),
-               MHD_itc_last_strerror_ ());
-#endif
-      free (daemon);
-      return NULL;
-    }
-  }
-  if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) &&
-       (1 == use_itc) &&
-       (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (daemon->itc),
-                                  NULL)) )
+  if (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD))
+    *pflags &= ~MHD_USE_ITC; /* useless if we are using 'external' select */
+  else
     {
-#ifdef HAVE_MESSAGES
-      MHD_DLOG (daemon,
-               _("file descriptor for inter-thread communication channel 
exceeds maximum value\n"));
+#ifdef HAVE_LISTEN_SHUTDOWN
+      if (0 != (*pflags & MHD_USE_NO_LISTEN_SOCKET))
 #endif
-      MHD_itc_destroy_chk_ (daemon->itc);
-      free (daemon);
-      return NULL;
+        *pflags |= MHD_USE_ITC; /* yes, must use ITC to signal thread */
     }
 #ifdef DAUTH_SUPPORT
   daemon->digest_auth_rand_size = 0;
@@ -5481,7 +5457,7 @@ MHD_start_daemon_va (unsigned int flags,
   daemon->nonce_nc_size = 4; /* tiny */
 #endif
 #ifdef HTTPS_SUPPORT
-  if (0 != (flags & MHD_USE_TLS))
+  if (0 != (*pflags & MHD_USE_TLS))
     {
       daemon->cred_type = GNUTLS_CRD_CERTIFICATE;
     }
@@ -5493,13 +5469,44 @@ MHD_start_daemon_va (unsigned int flags,
                                    ap))
     {
 #ifdef HTTPS_SUPPORT
-      if ( (0 != (flags & MHD_USE_TLS)) &&
+      if ( (0 != (*pflags & MHD_USE_TLS)) &&
           (NULL != daemon->priority_cache) )
        gnutls_priority_deinit (daemon->priority_cache);
 #endif /* HTTPS_SUPPORT */
       free (daemon);
       return NULL;
     }
+  if ( (0 != (*pflags & MHD_USE_ITC)) &&
+       (0 == daemon->worker_pool_size) )
+    {
+      if (! MHD_itc_init_ (daemon->itc))
+        {
+#ifdef HAVE_MESSAGES
+          MHD_DLOG (daemon,
+                    _("Failed to create inter-thread communication channel: 
%s\n"),
+                    MHD_itc_last_strerror_ ());
+#endif
+          if (NULL != daemon->priority_cache)
+            gnutls_priority_deinit (daemon->priority_cache);
+          free (daemon);
+          return NULL;
+        }
+      if ( (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL))) &&
+           (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (daemon->itc),
+                                      NULL)) )
+        {
+#ifdef HAVE_MESSAGES
+          MHD_DLOG (daemon,
+                    _("file descriptor for inter-thread communication channel 
exceeds maximum value\n"));
+#endif
+          MHD_itc_destroy_chk_ (daemon->itc);
+          if (NULL != daemon->priority_cache)
+            gnutls_priority_deinit (daemon->priority_cache);
+          free (daemon);
+          return NULL;
+        }
+    }
+
 #ifdef DAUTH_SUPPORT
   if (daemon->nonce_nc_size > 0)
     {
@@ -5511,7 +5518,7 @@ MHD_start_daemon_va (unsigned int flags,
                    _("Specified value for NC_SIZE too large\n"));
 #endif
 #ifdef HTTPS_SUPPORT
-         if (0 != (flags & MHD_USE_TLS))
+         if (0 != (*pflags & MHD_USE_TLS))
            gnutls_priority_deinit (daemon->priority_cache);
 #endif /* HTTPS_SUPPORT */
          free (daemon);
@@ -5526,7 +5533,7 @@ MHD_start_daemon_va (unsigned int flags,
                    MHD_strerror_ (errno));
 #endif
 #ifdef HTTPS_SUPPORT
-         if (0 != (flags & MHD_USE_TLS))
+         if (0 != (*pflags & MHD_USE_TLS))
            gnutls_priority_deinit (daemon->priority_cache);
 #endif /* HTTPS_SUPPORT */
          free (daemon);
@@ -5541,7 +5548,7 @@ MHD_start_daemon_va (unsigned int flags,
                _("MHD failed to initialize nonce-nc mutex\n"));
 #endif
 #ifdef HTTPS_SUPPORT
-      if (0 != (flags & MHD_USE_TLS))
+      if (0 != (*pflags & MHD_USE_TLS))
        gnutls_priority_deinit (daemon->priority_cache);
 #endif /* HTTPS_SUPPORT */
       free (daemon->nnc);
@@ -5551,7 +5558,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
 
   /* Thread pooling currently works only with internal select thread model */
-  if ( (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD)) &&
+  if ( (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) &&
        (daemon->worker_pool_size > 0) )
     {
 #ifdef HAVE_MESSAGES
@@ -5562,7 +5569,7 @@ MHD_start_daemon_va (unsigned int flags,
     }
 
 #ifdef __SYMBIAN32__
-  if (0 != (flags & (MHD_USE_INTERNAL_POLLING_THREAD | 
MHD_USE_THREAD_PER_CONNECTION)))
+  if (0 != (*pflags & (MHD_USE_INTERNAL_POLLING_THREAD | 
MHD_USE_THREAD_PER_CONNECTION)))
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
@@ -5572,10 +5579,10 @@ MHD_start_daemon_va (unsigned int flags,
     }
 #endif
   if ( (MHD_INVALID_SOCKET == daemon->listen_fd) &&
-       (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) )
+       (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
     {
       /* try to open listen socket */
-      listen_fd = MHD_socket_create_listen_(flags & MHD_USE_IPv6);
+      listen_fd = MHD_socket_create_listen_(*pflags & MHD_USE_IPv6);
       if (MHD_INVALID_SOCKET == listen_fd)
        {
 #ifdef HAVE_MESSAGES
@@ -5698,7 +5705,7 @@ MHD_start_daemon_va (unsigned int flags,
 
       /* check for user supplied sockaddr */
 #if HAVE_INET6
-      if (0 != (flags & MHD_USE_IPv6))
+      if (0 != (*pflags & MHD_USE_IPv6))
        addrlen = sizeof (struct sockaddr_in6);
       else
 #endif
@@ -5706,7 +5713,7 @@ MHD_start_daemon_va (unsigned int flags,
       if (NULL == servaddr)
        {
 #if HAVE_INET6
-         if (0 != (flags & MHD_USE_IPv6))
+         if (0 != (*pflags & MHD_USE_IPv6))
            {
              memset (&servaddr6,
                       0,
@@ -5734,7 +5741,7 @@ MHD_start_daemon_va (unsigned int flags,
        }
       daemon->listen_fd = listen_fd;
 
-      if (0 != (flags & MHD_USE_IPv6))
+      if (0 != (*pflags & MHD_USE_IPv6))
        {
 #ifdef IPPROTO_IPV6
 #ifdef IPV6_V6ONLY
@@ -5743,7 +5750,7 @@ MHD_start_daemon_va (unsigned int flags,
             and may also be missing on older POSIX systems; good luck if you 
have any of those,
             your IPv6 socket may then also bind against IPv4 anyway... */
          const MHD_SCKT_OPT_BOOL_ v6_only =
-            (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK));
+            (MHD_USE_DUAL_STACK != (*pflags & MHD_USE_DUAL_STACK));
          if (0 > setsockopt (listen_fd,
                               IPPROTO_IPV6, IPV6_V6ONLY,
                               (const void *) &v6_only,
@@ -5770,7 +5777,7 @@ MHD_start_daemon_va (unsigned int flags,
          goto free_and_fail;
        }
 #ifdef TCP_FASTOPEN
-      if (0 != (flags & MHD_USE_TCP_FASTOPEN))
+      if (0 != (*pflags & MHD_USE_TCP_FASTOPEN))
       {
         if (0 == daemon->fastopen_queue_size)
           daemon->fastopen_queue_size = MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT;
@@ -5813,7 +5820,7 @@ MHD_start_daemon_va (unsigned int flags,
                 _("Failed to set nonblocking mode on listening socket: %s\n"),
                 MHD_socket_last_strerr_());
 #endif
-      if (0 != (flags & MHD_USE_EPOLL) ||
+      if (0 != (*pflags & MHD_USE_EPOLL) ||
           daemon->worker_pool_size > 0)
         {
            /* Accept must be non-blocking. Multiple children may wake up
@@ -5826,7 +5833,7 @@ MHD_start_daemon_va (unsigned int flags,
   if ( (MHD_INVALID_SOCKET != listen_fd) &&
        (! MHD_SCKT_FD_FITS_FDSET_(listen_fd,
                                   NULL)) &&
-       (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) )
+       (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) )
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
@@ -5839,11 +5846,11 @@ MHD_start_daemon_va (unsigned int flags,
     }
 
 #ifdef EPOLL_SUPPORT
-  if ( (0 != (flags & MHD_USE_EPOLL)) &&
+  if ( (0 != (*pflags & MHD_USE_EPOLL)) &&
        (0 == daemon->worker_pool_size) &&
-       (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) )
+       (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
     {
-      if (0 != (flags & MHD_USE_THREAD_PER_CONNECTION))
+      if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))
        {
 #ifdef HAVE_MESSAGES
          MHD_DLOG (daemon,
@@ -5880,7 +5887,7 @@ MHD_start_daemon_va (unsigned int flags,
 
 #ifdef HTTPS_SUPPORT
   /* initialize HTTPS daemon certificate aspects & send / recv functions */
-  if ( (0 != (flags & MHD_USE_TLS)) &&
+  if ( (0 != (*pflags & MHD_USE_TLS)) &&
        (0 != MHD_TLS_init (daemon)) )
     {
 #ifdef HAVE_MESSAGES
@@ -5894,11 +5901,11 @@ MHD_start_daemon_va (unsigned int flags,
       goto free_and_fail;
     }
 #endif /* HTTPS_SUPPORT */
-  if ( ( (0 != (flags & MHD_USE_INTERNAL_POLLING_THREAD)) &&
+  if ( ( (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) &&
         (0 == daemon->worker_pool_size) ) &&
-       (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) &&
+       (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) &&
        (! MHD_create_named_thread_ (&daemon->pid,
-                                    (flags & MHD_USE_THREAD_PER_CONNECTION) ?
+                                    (*pflags & MHD_USE_THREAD_PER_CONNECTION) ?
                                     "MHD-listen" : "MHD-single",
                                     daemon->thread_stack_size,
                                     &MHD_select_thread,
@@ -5916,7 +5923,7 @@ MHD_start_daemon_va (unsigned int flags,
       goto free_and_fail;
     }
   if ( (daemon->worker_pool_size > 0) &&
-       (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) )
+       (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
     {
       /* Coarse-grained count of connections per thread (note error
        * due to integer division). Also keep track of how many
@@ -5948,8 +5955,7 @@ MHD_start_daemon_va (unsigned int flags,
           d->worker_pool_size = 0;
           d->worker_pool = NULL;
 
-          /* Always use individual control ITCs */
-          if (1)
+          if (0 != (*pflags & MHD_USE_ITC))
             {
               if (! MHD_itc_init_ (d->itc))
                 {
@@ -5960,17 +5966,17 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
                   goto thread_failed;
                 }
-            }
-          if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) &&
-               (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (d->itc),
-                                          NULL)) )
-            {
+              if ( (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL))) &&
+                   (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (d->itc),
+                                              NULL)) )
+                {
 #ifdef HAVE_MESSAGES
-              MHD_DLOG (daemon,
-                        _("File descriptor for worker inter-thread 
communication channel exceeds maximum value\n"));
+                  MHD_DLOG (daemon,
+                            _("File descriptor for worker inter-thread 
communication channel exceeds maximum value\n"));
 #endif
-              MHD_itc_destroy_chk_ (d->itc);
-              goto thread_failed;
+                  MHD_itc_destroy_chk_ (d->itc);
+                  goto thread_failed;
+                }
             }
 
           /* Divide available connections evenly amongst the threads.
@@ -5980,7 +5986,7 @@ MHD_start_daemon_va (unsigned int flags,
           if (i < leftover_conns)
             ++d->connection_limit;
 #ifdef EPOLL_SUPPORT
-         if ( (0 != (daemon->options & MHD_USE_EPOLL)) &&
+         if ( (0 != (*pflags & MHD_USE_EPOLL)) &&
               (MHD_YES != setup_epoll_to_listen (d)) )
            goto thread_failed;
 #endif
@@ -6072,7 +6078,7 @@ thread_failed:
   MHD_mutex_destroy_chk_ (&daemon->nnc_lock);
 #endif
 #ifdef HTTPS_SUPPORT
-  if (0 != (flags & MHD_USE_TLS))
+  if (0 != (*pflags & MHD_USE_TLS))
     gnutls_priority_deinit (daemon->priority_cache);
 #endif /* HTTPS_SUPPORT */
   if (MHD_ITC_IS_VALID_(daemon->itc))
@@ -6122,7 +6128,7 @@ close_all_connections (struct MHD_Daemon *daemon)
      running into the check for there not being any suspended
      connections left in case of a tight race with a recently
      resumed connection. */
-  if (0 != (MHD_ALLOW_SUSPEND_RESUME & daemon->options))
+  if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options))
     {
       daemon->resuming = true; /* Force check for pending resume. */
       resume_suspended_connections (daemon);
@@ -6245,7 +6251,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
   if (NULL == daemon)
     return;
 
-  if (0 != (MHD_ALLOW_SUSPEND_RESUME & daemon->options))
+  if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options))
     resume_suspended_connections (daemon);
 
   daemon->shutdown = true;
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 1356e92e..52bd8520 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -192,6 +192,12 @@ enum MHD_ConnectionEventLoopInfo
 
 
 /**
+ * Additional test value for enum MHD_FLAG to check only for 
MHD_ALLOW_SUSPEND_RESUME and
+ * NOT for MHD_USE_ITC.
+ */
+#define MHD_TEST_ALLOW_SUSPEND_RESUME 8192
+
+/**
  * Maximum length of a nonce in digest authentication.  32(MD5 Hex) +
  * 8(Timestamp Hex) + 1(NULL); hence 41 should suffice, but Opera
  * (already) takes more (see Mantis #1633), so we've increased the

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



reply via email to

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