summaryrefslogtreecommitdiff
path: root/listen.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-04 01:15:08 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-01-04 01:15:08 +0100
commit6384dde85bb0729137c4de3c1c994edc5d7c8091 (patch)
tree85f16a5917da8866e2099fbea321ed6a503568b8 /listen.c
parent5ee20abc0dea6e4187e212b1d8e9484f5e79f538 (diff)
fix resuming accept() calls after exceeding client limit
Diffstat (limited to 'listen.c')
-rw-r--r--listen.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/listen.c b/listen.c
index c4b6b2b..f11768a 100644
--- a/listen.c
+++ b/listen.c
@@ -56,7 +56,7 @@ void uh_unblock_listeners(void)
{
struct listener *l;
- if (!n_blocked && conf.max_requests &&
+ if ((!n_blocked && conf.max_requests) ||
n_clients >= conf.max_requests)
return;
@@ -64,6 +64,10 @@ void uh_unblock_listeners(void)
if (!l->blocked)
continue;
+ l->fd.cb(&l->fd, ULOOP_READ);
+ if (n_clients >= conf.max_requests)
+ break;
+
n_blocked--;
l->blocked = false;
uloop_fd_add(&l->fd, ULOOP_READ);
@@ -74,7 +78,10 @@ static void listener_cb(struct uloop_fd *fd, unsigned int events)
{
struct listener *l = container_of(fd, struct listener, fd);
- uh_accept_client(fd->fd);
+ while (1) {
+ if (!uh_accept_client(fd->fd))
+ break;
+ }
if (conf.max_requests && n_clients >= conf.max_requests)
uh_block_listener(l);