r2646 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Jun 2 21:45:07 CEST 2008


Author: phk
Date: 2008-06-02 21:45:05 +0200 (Mon, 02 Jun 2008)
New Revision: 2646

Modified:
   trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
Log:
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 <rafael.umann at terra.com.br>

Closes ticket #235



Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c	2008-05-31 21:26:20 UTC (rev 2645)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c	2008-06-02 19:45:05 UTC (rev 2646)
@@ -71,6 +71,8 @@
 {
 	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_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 @@
 				}
 			}
 		}
+		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) {




More information about the varnish-commit mailing list