aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-01-21 21:42:05 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-01-21 21:42:05 +0300
commit313e750c65cecfce85c1eed4f73c71196fecbac8 (patch)
treeada8a679208873ab09ef0fdcf537a70dee973a5a /src/microhttpd/daemon.c
parentd196c6cd6428ebb36a0bd90bfcd0bad422ef09ef (diff)
downloadlibmicrohttpd-313e750c65cecfce85c1eed4f73c71196fecbac8.tar.gz
libmicrohttpd-313e750c65cecfce85c1eed4f73c71196fecbac8.zip
Fixed processing epoll with many connections to accept.
If 'accept_pending' were set to 'true' not connection transfer occurred. Additionally 'accept_pending' never reset to false.
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 5a314578..5ae6f138 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -3691,7 +3691,6 @@ MHD_epoll (struct MHD_Daemon *daemon,
3691 MHD_UNSIGNED_LONG_LONG timeout_ll; 3691 MHD_UNSIGNED_LONG_LONG timeout_ll;
3692 int num_events; 3692 int num_events;
3693 unsigned int i; 3693 unsigned int i;
3694 unsigned int series_length;
3695#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 3694#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
3696 int run_upgraded = MHD_NO; 3695 int run_upgraded = MHD_NO;
3697#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 3696#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
@@ -3830,26 +3829,18 @@ MHD_epoll (struct MHD_Daemon *daemon,
3830 MHD_itc_clear_ (daemon->itc); 3829 MHD_itc_clear_ (daemon->itc);
3831 continue; 3830 continue;
3832 } 3831 }
3833 if ( (daemon == events[i].data.ptr) || 3832 if (daemon == events[i].data.ptr)
3834 (daemon->accept_pending) )
3835 { 3833 {
3836 /* run 'accept' until it fails or we are not allowed to take 3834 unsigned int series_length = 0;
3837 on more connections */ 3835 /* Run 'accept' until it fails or daemon at limit of connections.
3838 series_length = 0; 3836 * Do not accept more then 10 connections at once. The rest will
3839 while (MHD_YES == MHD_accept_connection (daemon)) 3837 * be accepted on next turn (level trigger is used for listen
3840 { 3838 * socket). */
3841 if ( (daemon->connections < daemon->connection_limit) && 3839 while ( (MHD_YES == MHD_accept_connection (daemon)) &&
3842 (series_length < 128) && 3840 (series_length < 10) &&
3843 (! daemon->at_limit) ) 3841 (daemon->connections < daemon->connection_limit) &&
3844 series_length++; 3842 (! daemon->at_limit) )
3845 else 3843 series_length++;
3846 {
3847 /* Use the 'accept_pending' flag to remember that we stopped
3848 for resource limits, not because we drained accept() */
3849 daemon->accept_pending = true;
3850 break;
3851 }
3852 }
3853 continue; 3844 continue;
3854 } 3845 }
3855 /* this is an event relating to a 'normal' connection, 3846 /* this is an event relating to a 'normal' connection,