From: phk Date: Mon, 2 Jun 2008 19:45:05 +0000 (+0000) Subject: Add a "timeout counter" and cleans the timeout sockets every 60 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7d266a0b8fc1dc04b7c15c9c330f37170a58e6b;p=varnish Add a "timeout counter" and cleans the timeout sockets every 60 seconds instead of cleaning it in every new connection received. We are using it here, and the performance is much better now. Submmitted by: Rafael Umann Closes ticket #235 git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2646 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_acceptor_epoll.c b/varnish-cache/bin/varnishd/cache_acceptor_epoll.c index eeddb427..8652d723 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_epoll.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_epoll.c @@ -71,6 +71,8 @@ vca_main(void *arg) { struct epoll_event ev; double deadline; + int dotimer = 0; + double last_timeout = 0, tmp_timeout; struct sess *sp, *sp2; int i; @@ -83,7 +85,7 @@ vca_main(void *arg) vca_add(vca_pipes[0], vca_pipes); while (1) { - if (epoll_wait(epfd, &ev, 1, 100) > 0) { + if ((dotimer = epoll_wait(epfd, &ev, 1, 100)) > 0) { if (ev.data.ptr == vca_pipes) { i = read(vca_pipes[0], &sp, sizeof sp); assert(i == sizeof sp); @@ -100,6 +102,14 @@ vca_main(void *arg) } } } + tmp_timeout = TIM_mono(); + if ((tmp_timeout - last_timeout) > 60) { + last_timeout = tmp_timeout; + } else { + if (dotimer > 0) + continue; + } + /* check for timeouts */ deadline = TIM_real() - params->sess_timeout; VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {