gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (a44c8f33 -> 78295468


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (a44c8f33 -> 78295468)
Date: Tue, 28 Feb 2017 17:52:20 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from a44c8f33 configure.ac: fixed detection of tsearch-related functions 
and header. Precompiler macro HAVE_SEARCH_H is used by code and must be 
appropriately defined.
     new 5cdd75f2 configure.ac: skip large GnuTLS and gcrypt tests if HTTPS is 
disabled
     new 0b4e8535 MHD_get_timeout(): fixed incorrect timeout for TLS 
connections. If connection is in "MHD_EVENT_LOOP_INFO_WRITE" mode, any pending 
incoming data should not result in zero timeout. Already handled properly by 
'data_already_pending'. Note: old check was incorrect even for 
"MHD_EVENT_LOOP_INFO_READ" connections as only first connection in "normal 
timeout" list was checked.
     new abc6bac2 MHD_get_timeout(): fixed return of latest timeout instead of 
earliest.
     new a5b2b99e MHD_get_timeout(): one more 'int' -> 'bool' replacement.
     new 78295468 Walk double-linked lists from 'tail' to 'head'. Walking 
connection as "First in - First Served" gives more uniform processing time.

The 5 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:
 configure.ac            |  37 +++++++++++-------
 src/microhttpd/daemon.c | 102 ++++++++++++++++++++++--------------------------
 2 files changed, 68 insertions(+), 71 deletions(-)

diff --git a/configure.ac b/configure.ac
index d1ce5d42..5fbfb83b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1088,6 +1088,22 @@ AC_CHECK_PROG([have_socat],[socat], [yes], [no])
 AM_CONDITIONAL([HAVE_ZZUF], [test "x$have_zzuf" = "xyes"])
 AM_CONDITIONAL([HAVE_SOCAT], [test "x$have_socat" = "xyes"])
 
+GNUTLS_CPPFLAGS=""
+GNUTLS_LDFLAGS=""
+have_gnutls=no
+have_gnutls_sni=no
+have_gcrypt=no
+
+# optional: HTTPS support.  Enabled by default
+AC_ARG_ENABLE([https],
+   [AS_HELP_STRING([--enable-https],
+               [enable HTTPS support (yes, no, auto)[auto]])],
+   [enable_https=${enableval}])
+if test "x$enable_https" != "xno"
+then
+#
+# Next block is large unindented block
+#
 
 # libgcrypt linkage: required for HTTPS support
 AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
@@ -1104,10 +1120,6 @@ then
 fi
 
 # gnutls
-GNUTLS_CPPFLAGS=""
-GNUTLS_LDFLAGS=""
-have_gnutls=no
-have_gnutls_sni=no
 have_gnutls_pkgcfg=no
 AC_MSG_CHECKING([[how to find GnuTLS library]])
 AC_ARG_WITH([[gnutls]],
@@ -1209,22 +1221,14 @@ AS_IF([test "x$with_gnutls" != "xno" && test 
"x$have_gnutls" != "xyes"],
 
 AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"], 
[AC_MSG_ERROR([[can't find usable libgnutls]])])
 
-AM_CONDITIONAL(HAVE_GNUTLS, test "x$have_gnutls" = "xyes")
-AM_CONDITIONAL([HAVE_GNUTLS_SNI], [test "x$have_gnutls_sni" = "xyes"])
-
 AC_SUBST([GNUTLS_CPPFLAGS])
 AC_SUBST([GNUTLS_CFLAGS])
 AC_SUBST([GNUTLS_LDFLAGS])
 AC_SUBST([GNUTLS_LIBS])
 
-# optional: HTTPS support.  Enabled by default
-AC_MSG_CHECKING(whether to support HTTPS)
-AC_ARG_ENABLE([https],
-   [AS_HELP_STRING([--enable-https],
-               [enable HTTPS support (yes, no, auto)[auto]])],
-   [enable_https=${enableval}])
-if test "x$enable_https" != "xno"
-then
+#
+# End of large unindented block
+#
   AS_IF([test "x$have_gnutls" = "xyes" && test "x$have_gcrypt" = "xyes"], [
           AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is 
compiled with HTTPS support.])
           enable_https=yes
@@ -1253,8 +1257,11 @@ then
 else
   MSG_HTTPS="no (disabled)"
 fi
+AC_MSG_CHECKING(whether to support HTTPS)
 AC_MSG_RESULT([$MSG_HTTPS])
 
+AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]])
+AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]])
 AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"])
 
 # optional: HTTP Basic Auth support. Enabled by default
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index a6b1af89..2e3d8833 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -819,9 +819,10 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
                               fd_setsize)) )
     result = MHD_NO;
 
-  for (pos = daemon->connections_head; NULL != pos; pos = posn)
+  /* Start from oldest connections. Make sense for W32 FDSETs. */
+  for (pos = daemon->connections_tail; NULL != pos; pos = posn)
     {
-      posn = pos->next;
+      posn = pos->prev;
 
       switch (pos->event_loop_info)
        {
@@ -856,7 +857,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
   {
     struct MHD_UpgradeResponseHandle *urh;
 
-    for (urh = daemon->urh_head; NULL != urh; urh = urh->next)
+    for (urh = daemon->urh_tail; NULL != urh; urh = urh->prev)
       {
         if (MHD_NO ==
             urh_to_fdset (urh,
@@ -2547,26 +2548,26 @@ static int
 resume_suspended_connections (struct MHD_Daemon *daemon)
 {
   struct MHD_Connection *pos;
-  struct MHD_Connection *next = NULL;
+  struct MHD_Connection *prev = NULL;
   int ret;
 
   ret = MHD_NO;
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
 
   if (daemon->resuming)
-    next = daemon->suspended_connections_head;
+    prev = daemon->suspended_connections_tail;
 
   EXTRA_CHECK(NULL != next);
   daemon->resuming = false;
 
-  while (NULL != (pos = next))
+  while (NULL != (pos = prev))
     {
 #ifdef UPGRADE_SUPPORT
       struct MHD_UpgradeResponseHandle * const urh = pos->urh;
 #else  /* ! UPGRADE_SUPPORT */
       static const void * const urh = NULL;
 #endif /* ! UPGRADE_SUPPORT */
-      next = pos->next;
+      prev = pos->prev;
       if ( (! pos->resuming)
 #ifdef UPGRADE_SUPPORT
           || ( (NULL != urh) &&
@@ -2855,7 +2856,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
   struct MHD_Connection *pos;
 
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-  while (NULL != (pos = daemon->cleanup_head))
+  while (NULL != (pos = daemon->cleanup_tail))
     {
       DLL_remove (daemon->cleanup_head,
                  daemon->cleanup_tail,
@@ -2955,7 +2956,7 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
   time_t earliest_deadline;
   time_t now;
   struct MHD_Connection *pos;
-  int have_timeout;
+  bool have_timeout;
 
   if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
@@ -2983,40 +2984,30 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
     }
 #endif /* EPOLL_SUPPORT */
 
-  have_timeout = MHD_NO;
+  have_timeout = false;;
   earliest_deadline = 0; /* avoid compiler warnings */
-  for (pos = daemon->manual_timeout_head; NULL != pos; pos = pos->nextX)
+  for (pos = daemon->manual_timeout_tail; NULL != pos; pos = pos->prevX)
     {
       if (0 != pos->connection_timeout)
        {
          if ( (! have_timeout) ||
               (earliest_deadline > pos->last_activity + 
pos->connection_timeout) )
            earliest_deadline = pos->last_activity + pos->connection_timeout;
-#ifdef HTTPS_SUPPORT
-         if (  (0 != (daemon->options & MHD_USE_TLS)) &&
-               (0 != gnutls_record_check_pending (pos->tls_session)) )
-           earliest_deadline = 0;
-#endif /* HTTPS_SUPPORT */
-         have_timeout = MHD_YES;
+         have_timeout = true;
        }
     }
-  /* normal timeouts are sorted, so we only need to look at the 'head' */
-  pos = daemon->normal_timeout_head;
+  /* normal timeouts are sorted, so we only need to look at the 'tail' 
(oldest) */
+  pos = daemon->normal_timeout_tail;
   if ( (NULL != pos) &&
        (0 != pos->connection_timeout) )
     {
       if ( (! have_timeout) ||
           (earliest_deadline > pos->last_activity + pos->connection_timeout) )
        earliest_deadline = pos->last_activity + pos->connection_timeout;
-#ifdef HTTPS_SUPPORT
-      if (  (0 != (daemon->options & MHD_USE_TLS)) &&
-           (0 != gnutls_record_check_pending (pos->tls_session)) )
-       earliest_deadline = 0;
-#endif /* HTTPS_SUPPORT */
-      have_timeout = MHD_YES;
+      have_timeout = true;
     }
 
-  if (MHD_NO == have_timeout)
+  if (have_timeout)
     return MHD_NO;
   now = MHD_monotonic_sec_counter();
   if (earliest_deadline < now)
@@ -3060,7 +3051,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
 {
   MHD_socket ds;
   struct MHD_Connection *pos;
-  struct MHD_Connection *next;
+  struct MHD_Connection *prev;
 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
   struct MHD_UpgradeResponseHandle *urh;
   struct MHD_UpgradeResponseHandle *urhn;
@@ -3109,10 +3100,10 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
   if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
       /* do not have a thread per connection, process all connections now */
-      next = daemon->connections_head;
-      while (NULL != (pos = next))
+      prev = daemon->connections_tail;
+      while (NULL != (pos = prev))
         {
-         next = pos->next;
+         prev = pos->next;
           ds = pos->socket_fd;
           if (MHD_INVALID_SOCKET == ds)
            continue;
@@ -3128,9 +3119,9 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
 
 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
   /* handle upgraded HTTPS connections */
-  for (urh = daemon->urh_head; NULL != urh; urh = urhn)
+  for (urh = daemon->urh_tail; NULL != urh; urh = urhn)
     {
-      urhn = urh->next;
+      urhn = urh->prev;
       /* update urh state based on select() output */
       urh_from_fdset (urh,
                       read_fd_set,
@@ -3335,7 +3326,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
 {
   unsigned int num_connections;
   struct MHD_Connection *pos;
-  struct MHD_Connection *next;
+  struct MHD_Connection *prev;
 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
   struct MHD_UpgradeResponseHandle *urh;
   struct MHD_UpgradeResponseHandle *urhn;
@@ -3406,7 +3397,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
       timeout = (ltimeout > INT_MAX) ? INT_MAX : (int) ltimeout;
 
     i = 0;
-    for (pos = daemon->connections_head; NULL != pos; pos = pos->next)
+    for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev)
       {
        p[poll_server+i].fd = pos->socket_fd;
        switch (pos->event_loop_info)
@@ -3427,7 +3418,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
        i++;
       }
 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
-    for (urh = daemon->urh_head; NULL != urh; urh = urh->next)
+    for (urh = daemon->urh_tail; NULL != urh; urh = urh->prev)
       {
         p[poll_server+i].fd = urh->connection->socket_fd;
         if (urh->in_buffer_used < urh->in_buffer_size)
@@ -3484,10 +3475,10 @@ MHD_poll_all (struct MHD_Daemon *daemon,
         return MHD_NO;
       }
     i = 0;
-    next = daemon->connections_head;
-    while (NULL != (pos = next))
+    prev = daemon->connections_tail;
+    while (NULL != (pos = prev))
       {
-       next = pos->next;
+       prev = pos->prev;
         /* first, sanity checks */
         if (i >= num_connections)
           break; /* connection list changed somehow, retry later ... */
@@ -3500,14 +3491,14 @@ MHD_poll_all (struct MHD_Daemon *daemon,
         i++;
       }
 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
-    for (urh = daemon->urh_head; NULL != urh; urh = urhn)
+    for (urh = daemon->urh_tail; NULL != urh; urh = urhn)
       {
         if (i >= num_connections)
           break; /* connection list changed somehow, retry later ... */
 
         /* Get next connection here as connection can be removed
          * from 'daemon->urh_head' list. */
-        urhn = urh->next;
+        urhn = urh->prev;
         /* Check for fd mismatch. FIXME: required for safety? */
         if (p[poll_server+i].fd == urh->connection->socket_fd)
           {
@@ -3765,7 +3756,6 @@ MHD_epoll (struct MHD_Daemon *daemon,
   static const char *upgrade_marker = "upgrade_ptr";
 #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
   struct MHD_Connection *pos;
-  struct MHD_Connection *next;
   struct MHD_Connection *prev;
   struct epoll_event events[MAX_EVENTS];
   struct epoll_event event;
@@ -4028,20 +4018,20 @@ MHD_epoll (struct MHD_Daemon *daemon,
 
      Connections with custom timeouts must all be looked at, as we
      do not bother to sort that (presumably very short) list. */
-  next = daemon->manual_timeout_head;
-  while (NULL != (pos = next))
+  prev = daemon->manual_timeout_tail;
+  while (NULL != (pos = prev))
     {
-      next = pos->nextX;
+      prev = pos->prevX;
       pos->idle_handler (pos);
     }
   /* Connections with the default timeout are sorted by prepending
      them to the head of the list whenever we touch the connection;
      thus it suffices to iterate from the tail until the first
      connection is NOT timed out */
-  next = daemon->normal_timeout_tail;
-  while (NULL != (pos = next))
+  prev = daemon->normal_timeout_tail;
+  while (NULL != (pos = prev))
     {
-      next = pos->prevX;
+      prev = pos->prevX;
       pos->idle_handler (pos);
       if (MHD_CONNECTION_CLOSED != pos->state)
        break; /* sorted by timeout, no need to visit the rest! */
@@ -5667,9 +5657,9 @@ close_all_connections (struct MHD_Daemon *daemon)
 
   /* give upgraded HTTPS connections a chance to finish */
   /* 'daemon->urh_head' is not used in thread-per-connection mode. */
-  for (urh = daemon->urh_head; NULL != urh; urh = urhn)
+  for (urh = daemon->urh_tail; NULL != urh; urh = urhn)
     {
-      urhn = urh->next;
+      urhn = urh->prev;
       /* call generic forwarding function for passing data
          with chance to detect that application is done. */
       process_urh (urh);
@@ -5697,7 +5687,7 @@ close_all_connections (struct MHD_Daemon *daemon)
     {
       struct MHD_Connection * susp;
 
-      susp = daemon->suspended_connections_head;
+      susp = daemon->suspended_connections_tail;
       while (NULL != susp)
         {
           if (NULL == susp->urh) /* "Upgraded" connection? */
@@ -5726,14 +5716,14 @@ close_all_connections (struct MHD_Daemon *daemon)
               susp->resuming = true;
               daemon->resuming = true;
             }
-          susp = susp->next;
+          susp = susp->prev;
         }
     }
   else /* This 'else' is combined with next 'if' */
 #endif /* UPGRADE_SUPPORT */
   if (NULL != daemon->suspended_connections_head)
     MHD_PANIC (_("MHD_stop_daemon() called while we have suspended 
connections.\n"));
-  for (pos = daemon->connections_head; NULL != pos; pos = pos->next)
+  for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev)
     {
       shutdown (pos->socket_fd,
                 SHUT_RDWR);
@@ -5748,7 +5738,7 @@ close_all_connections (struct MHD_Daemon *daemon)
   /* now, collect per-connection threads */
   if (used_thr_p_c)
     {
-      pos = daemon->connections_head;
+      pos = daemon->connections_tail;
       while (NULL != pos)
       {
         if (! pos->thread_joined)
@@ -5760,10 +5750,10 @@ close_all_connections (struct MHD_Daemon *daemon)
             pos->thread_joined = true;
             /* The thread may have concurrently modified the DLL,
                need to restart from the beginning */
-            pos = daemon->connections_head;
+            pos = daemon->connections_tail;
             continue;
           }
-        pos = pos->next;
+        pos = pos->prev;
       }
     }
   MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
@@ -5781,7 +5771,7 @@ close_all_connections (struct MHD_Daemon *daemon)
 #endif /* UPGRADE_SUPPORT */
 
   /* now that we're alone, move everyone to cleanup */
-  while (NULL != (pos = daemon->connections_head))
+  while (NULL != (pos = daemon->connections_tail))
   {
     if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
          (! pos->thread_joined) )

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



reply via email to

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