From b46fa4497b402df993dd9917b73d88e4d966c099 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Fri, 23 Sep 2005 16:31:49 +0000 Subject: [PATCH] only accept 100 connection in one round to remove the starvation of waiting connections git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@732 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/network.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/network.c b/src/network.c index 33aa4b6d..90023358 100644 --- a/src/network.c +++ b/src/network.c @@ -30,6 +30,7 @@ handler_t network_server_handle_fdevent(void *s, void *context, int revents) { server *srv = (server *)s; server_socket *srv_socket = (server_socket *)context; connection *con; + int loops = 0; UNUSED(context); @@ -40,8 +41,11 @@ handler_t network_server_handle_fdevent(void *s, void *context, int revents) { revents); return HANDLER_ERROR; } - - while (NULL != (con = connection_accept(srv, srv_socket))) { + + /* accept()s at most 100 connections directly + * + * we jump out after 100 to give the waiting connections a chance */ + for (loops = 0; loops < 100 && NULL != (con = connection_accept(srv, srv_socket)); loops++) { handler_t r; connection_state_machine(srv, con);