]> err.no Git - varnish/commitdiff
Add a "timeout counter" and cleans the timeout sockets every 60
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 2 Jun 2008 19:45:05 +0000 (19:45 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 2 Jun 2008 19:45:05 +0000 (19:45 +0000)
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 <rafael.umann@terra.com.br>

Closes ticket #235

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2646 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_acceptor_epoll.c

index eeddb427a6493174f25938b6219824db9e8bc424..8652d7234a85453f17ede1b952b29d8367f3708b 100644 (file)
@@ -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) {