[3.0] 0854c5d Make it possible to limit the total transfer time.

Tollef Fog Heen tfheen at varnish-cache.org
Mon Apr 16 10:20:38 CEST 2012


commit 0854c5dc0874b0e5752fb0621fd7bee1c196eb88
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Mon Nov 7 14:20:06 2011 +0100

    Make it possible to limit the total transfer time.
    
    Set the default total transfer time to 600s.

diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c
index 2b3f87e..007fe6e 100644
--- a/bin/varnishd/cache_acceptor.c
+++ b/bin/varnishd/cache_acceptor.c
@@ -234,9 +234,9 @@ vca_acct(void *arg)
 	t0 = TIM_real();
 	while (1) {
 #ifdef SO_SNDTIMEO_WORKS
-		if (params->send_timeout != send_timeout) {
+		if (params->idle_send_timeout != send_timeout) {
 			need_test = 1;
-			send_timeout = params->send_timeout;
+			send_timeout = params->idle_send_timeout;
 			tv_sndtimeo = TIM_timeval(send_timeout);
 			VTAILQ_FOREACH(ls, &heritage.socks, list) {
 				if (ls->sock < 0)
diff --git a/bin/varnishd/cache_wrw.c b/bin/varnishd/cache_wrw.c
index 286bc45..90af92a 100644
--- a/bin/varnishd/cache_wrw.c
+++ b/bin/varnishd/cache_wrw.c
@@ -133,6 +133,14 @@ WRW_Flush(struct worker *w)
 			*/
 			size_t used = 0;
 
+			if (TIM_real() - w->sp->t_resp > params->send_timeout) {
+				WSL(w, SLT_Debug, *wrw->wfd,
+				    "Hit total send timeout, wrote = %ld/%ld; not retrying",
+				    i, wrw->liov);
+				i = -1;
+				break;
+			}
+
 			WSL(w, SLT_Debug, *wrw->wfd,
 			    "Hit send timeout, wrote = %ld/%ld; retrying",
 			    i, wrw->liov);
diff --git a/bin/varnishd/heritage.h b/bin/varnishd/heritage.h
index daf4a1c..3f8330e 100644
--- a/bin/varnishd/heritage.h
+++ b/bin/varnishd/heritage.h
@@ -110,6 +110,7 @@ struct params {
 	unsigned		sess_timeout;
 	unsigned		pipe_timeout;
 	unsigned		send_timeout;
+	unsigned		idle_send_timeout;
 
 	/* Management hints */
 	unsigned		auto_restart;
diff --git a/bin/varnishd/mgt_param.c b/bin/varnishd/mgt_param.c
index b3ec8b9..76d9fe2 100644
--- a/bin/varnishd/mgt_param.c
+++ b/bin/varnishd/mgt_param.c
@@ -612,6 +612,13 @@ static const struct parspec input_parspec[] = {
                 "seconds the session is closed. \n"
 		"See setsockopt(2) under SO_SNDTIMEO for more information.",
 		DELAYED_EFFECT,
+		"600", "seconds" },
+	{ "idle_send_timeout", tweak_timeout, &master.idle_send_timeout, 0, 0,
+		"Time to wait with no data sent. "
+		"If no data has been transmitted in this many\n"
+                "seconds the session is closed. \n"
+		"See setsockopt(2) under SO_SNDTIMEO for more information.",
+		DELAYED_EFFECT,
 		"60", "seconds" },
 	{ "auto_restart", tweak_bool, &master.auto_restart, 0, 0,
 		"Restart child process automatically if it dies.\n",



More information about the varnish-commit mailing list