r4310 - in branches/2.0/varnish-cache/bin: varnishd varnishtest/tests

tfheen at projects.linpro.no tfheen at projects.linpro.no
Thu Oct 8 16:39:24 CEST 2009


Author: tfheen
Date: 2009-10-08 16:39:23 +0200 (Thu, 08 Oct 2009)
New Revision: 4310

Added:
   branches/2.0/varnish-cache/bin/varnishtest/tests/c00028.vtc
Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_center.c
Log:
Merge r4204: Prevent infinite restart recursion

it was possible to have infinite recursion between vcl_error returning
restart and cnt_recv calling vcl_error when you had too many restarts



Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-10-08 14:34:44 UTC (rev 4309)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-10-08 14:39:23 UTC (rev 4310)
@@ -349,13 +349,15 @@
 		    http_StatusMessage(sp->err_code));
 	VCL_error_method(sp);
 
-	if (sp->handling == VCL_RET_RESTART) {
+	if (sp->handling == VCL_RET_RESTART && sp->restarts <  params->max_restarts) {
 		HSH_Drop(sp);
 		sp->director = NULL;
 		sp->restarts++;
 		sp->step = STP_RECV;
 		return (0);
-	}
+	} else if (sp->handling == VCL_RET_RESTART)
+		sp->handling = VCL_RET_DELIVER;
+		  
 
 	/* We always close when we take this path */
 	sp->doclose = "error";

Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/c00028.vtc (from rev 4204, trunk/varnish-cache/bin/varnishtest/tests/c00028.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/c00028.vtc	                        (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/c00028.vtc	2009-10-08 14:39:23 UTC (rev 4310)
@@ -0,0 +1,24 @@
+# $Id$
+
+test "Test that we can't recurse restarts forever"
+
+varnish v1 -vcl { 
+	backend bad { 
+		.host = "127.0.0.1";
+		.port = "9090";
+	}
+
+	sub vcl_recv {
+	    set req.backend = bad;
+	}
+	sub vcl_error { 
+	    restart; 
+	}
+ } -start 
+
+client c1 {
+        txreq -url "/"
+        rxresp
+        expect resp.status == 503
+} -run
+



More information about the varnish-commit mailing list