r5644 - in trunk/varnish-cache/bin: varnishd varnishtest/tests
martin at varnish-cache.org
martin at varnish-cache.org
Mon Dec 13 15:40:46 CET 2010
Author: martin
Date: 2010-12-13 15:40:46 +0100 (Mon, 13 Dec 2010)
New Revision: 5644
Added:
trunk/varnish-cache/bin/varnishtest/tests/r00411.vtc
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
Implement restart in vcl_deliver(), and add test case for it.
Fixes: #411
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-12-13 08:10:48 UTC (rev 5643)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-12-13 14:40:46 UTC (rev 5644)
@@ -191,8 +191,18 @@
case VCL_RET_DELIVER:
break;
case VCL_RET_RESTART:
- INCOMPL();
- break;
+ if (sp->restarts >= params->max_restarts)
+ break;
+ (void)HSH_Deref(sp->wrk, NULL, &sp->obj);
+ AZ(sp->obj);
+ sp->restarts++;
+ sp->director = NULL;
+ sp->wrk->bereq = NULL;
+ sp->wrk->beresp = NULL;
+ sp->wrk->beresp1 = NULL;
+ sp->wrk->resp = NULL;
+ sp->step = STP_RECV;
+ return (0);
default:
WRONG("Illegal action in vcl_deliver{}");
}
Added: trunk/varnish-cache/bin/varnishtest/tests/r00411.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00411.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00411.vtc 2010-12-13 14:40:46 UTC (rev 5644)
@@ -0,0 +1,48 @@
+# $Id$
+
+test "Test restart in vcl_deliver"
+
+server s1 {
+ rxreq
+ expect req.url == "/foo"
+ txresp -status 303 -hdr "Location: /bar"
+
+ rxreq
+ expect req.url == "/bar"
+ txresp -status 200 -body "1"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_hit {
+ if (obj.http.X-Magic-Redirect == "1") {
+ set req.url = obj.http.Location;
+ return (restart);
+ }
+ }
+ sub vcl_fetch {
+ if (beresp.status == 303) {
+ set beresp.cacheable = true;
+ set beresp.http.X-Magic-Redirect = "1";
+ }
+ }
+ sub vcl_deliver {
+ if (resp.http.X-Magic-Redirect == "1") {
+ return (restart);
+ }
+ set resp.http.X-Restarts = req.restarts;
+ }
+} -start
+
+client c1 {
+ txreq -url "/foo"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 1
+ expect resp.http.X-Restarts == "2"
+
+ txreq -url "/foo"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 1
+ expect resp.http.X-Restarts == "1"
+} -run
Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00411.vtc
___________________________________________________________________
Added: svn:keywords
+ Id
More information about the varnish-commit
mailing list