gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (9665bdd0 -> 1125f7dd)


From: gnunet
Subject: [libmicrohttpd] branch master updated (9665bdd0 -> 1125f7dd)
Date: Wed, 07 Oct 2020 20:38:55 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 9665bdd0 memorypool: fixed assert for an edge situation
     new 0c2f6090 MHD_epoll: separate epoll results processing from external 
data processing
     new 1125f7dd MHD_epoll: handle timeout before data processing Connection 
should not timeout if it gets new data while processing data on other 
connections

The 2 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/microhttpd/daemon.c | 82 +++++++++++++++++++++++++++----------------------
 1 file changed, 45 insertions(+), 37 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 31ef6909..22b0a775 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4373,6 +4373,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
   bool run_upgraded = false;
 #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
+  bool need_to_accept;
 
   if (-1 == daemon->epoll_fd)
     return MHD_NO; /* we're down! */
@@ -4474,6 +4475,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
    * signaled in epoll mode by non-empty eready DLL. */
   daemon->data_already_pending = false;
 
+  need_to_accept = false;
   /* drain 'epoll' event queue; need to iterate as we get at most
      MAX_EVENTS in one system call here; in practice this should
      pretty much mean only one round, but better an extra loop here
@@ -4525,18 +4527,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
         /* Check for error conditions on listen socket. */
         /* FIXME: Initiate MHD_quiesce_daemon() to prevent busy waiting? */
         if (0 == (events[i].events & (EPOLLERR | EPOLLHUP)))
-        {
-          unsigned int series_length = 0;
-          /* Run 'accept' until it fails or daemon at limit of connections.
-           * Do not accept more then 10 connections at once. The rest will
-           * be accepted on next turn (level trigger is used for listen
-           * socket). */
-          while ( (MHD_NO != MHD_accept_connection (daemon)) &&
-                  (series_length < 10) &&
-                  (daemon->connections < daemon->connection_limit) &&
-                  (! daemon->at_limit) )
-            series_length++;
-        }
+          need_to_accept = true;
         continue;
       }
       /* this is an event relating to a 'normal' connection,
@@ -4586,6 +4577,48 @@ MHD_epoll (struct MHD_Daemon *daemon,
     }
   }
 
+  if (need_to_accept)
+  {
+    unsigned int series_length = 0;
+
+    /* Run 'accept' until it fails or daemon at limit of connections.
+     * Do not accept more then 10 connections at once. The rest will
+     * be accepted on next turn (level trigger is used for listen
+     * socket). */
+    while ( (MHD_NO != MHD_accept_connection (daemon)) &&
+            (series_length < 10) &&
+            (daemon->connections < daemon->connection_limit) &&
+            (! daemon->at_limit) )
+      series_length++;
+  }
+
+  /* Handle timed-out connections; we need to do this here
+     as the epoll mechanism won't call the 'MHD_connection_handle_idle()' on 
everything,
+     as the other event loops do.  As timeouts do not get an explicit
+     event, we need to find those connections that might have timed out
+     here.
+
+     Connections with custom timeouts must all be looked at, as we
+     do not bother to sort that (presumably very short) list. */
+  prev = daemon->manual_timeout_tail;
+  while (NULL != (pos = prev))
+  {
+    prev = pos->prevX;
+    MHD_connection_handle_idle (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 */
+  prev = daemon->normal_timeout_tail;
+  while (NULL != (pos = prev))
+  {
+    prev = pos->prevX;
+    MHD_connection_handle_idle (pos);
+    if (MHD_CONNECTION_CLOSED != pos->state)
+      break; /* sorted by timeout, no need to visit the rest! */
+  }
+
 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
   if (run_upgraded || (NULL != daemon->eready_urh_head))
     run_epoll_for_upgrade (daemon);
@@ -4618,31 +4651,6 @@ MHD_epoll (struct MHD_Daemon *daemon,
     }
   }
 
-  /* Finally, handle timed-out connections; we need to do this here
-     as the epoll mechanism won't call the 'MHD_connection_handle_idle()' on 
everything,
-     as the other event loops do.  As timeouts do not get an explicit
-     event, we need to find those connections that might have timed out
-     here.
-
-     Connections with custom timeouts must all be looked at, as we
-     do not bother to sort that (presumably very short) list. */prev = 
daemon->manual_timeout_tail;
-  while (NULL != (pos = prev))
-  {
-    prev = pos->prevX;
-    MHD_connection_handle_idle (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 */
-  prev = daemon->normal_timeout_tail;
-  while (NULL != (pos = prev))
-  {
-    prev = pos->prevX;
-    MHD_connection_handle_idle (pos);
-    if (MHD_CONNECTION_CLOSED != pos->state)
-      break; /* sorted by timeout, no need to visit the rest! */
-  }
   return MHD_YES;
 }
 

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