[PATCH] Stop accept() timeouts from being counted as sess_fail in varnishstat

Martin Blix Grydeland martin at varnish-software.com
Thu Jan 19 16:35:58 CET 2012

Varnish sets SO_RCVTIMEO to cache_param->timeout_idle on the listen
sockets, so that the value is inherited to the accept()ed
connections. This has the side effect of making accept() returning
with EAGAIN after cache_param->timeout_idle seconds when there are no
connections coming in, and each of these timeouts is counted as a
sess_failed. Also the pacing sleep time is increased for each of these
timeouts, causing Varnish to react slowly at first when connections
start coming in.

Patch changes to loop around the call to accept() while EAGAIN
 bin/varnishd/cache/cache_acceptor.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index d55545b..7918a6a 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -186,7 +186,10 @@ VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa)
 	wa->acceptaddrlen = sizeof wa->acceptaddr;
-	i = accept(ls->sock, (void*)&wa->acceptaddr, &wa->acceptaddrlen);
+	do {
+		i = accept(ls->sock, (void*)&wa->acceptaddr,
+			   &wa->acceptaddrlen);
+	} while (i < 0 && errno == EAGAIN);
 	if (i < 0) {
 		switch (errno) {

More information about the varnish-dev mailing list