r3948 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl
kristian at projects.linpro.no
kristian at projects.linpro.no
Wed Mar 18 12:25:43 CET 2009
Author: kristian
Date: 2009-03-18 12:25:43 +0100 (Wed, 18 Mar 2009)
New Revision: 3948
Added:
trunk/varnish-cache/bin/varnishtest/tests/c00024.vtc
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/include/vcl_returns.h
trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
Log:
Allow restart in vcl_error
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2009-03-18 10:22:51 UTC (rev 3947)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2009-03-18 11:25:43 UTC (rev 3948)
@@ -306,10 +306,6 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- /* We always close when we take this path */
- sp->doclose = "error";
- sp->wantbody = 1;
-
w = sp->wrk;
if (sp->obj == NULL) {
HSH_Prealloc(sp);
@@ -335,6 +331,19 @@
http_PutResponse(w, sp->fd, h,
http_StatusMessage(sp->err_code));
VCL_error_method(sp);
+
+ if (sp->handling == VCL_RET_RESTART) {
+ HSH_Drop(sp);
+ sp->director = NULL;
+ sp->restarts++;
+ sp->step = STP_RECV;
+ return (0);
+ }
+
+ /* We always close when we take this path */
+ sp->doclose = "error";
+ sp->wantbody = 1;
+
assert(sp->handling == VCL_RET_DELIVER);
sp->err_code = 0;
sp->err_reason = NULL;
Added: trunk/varnish-cache/bin/varnishtest/tests/c00024.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/c00024.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/c00024.vtc 2009-03-18 11:25:43 UTC (rev 3948)
@@ -0,0 +1,38 @@
+# $Id$
+
+test "Test restart in vcl_error"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl {
+ backend bad {
+ .host = "127.0.0.1";
+ .port = "9099";
+ }
+ backend good {
+ .host = "127.0.0.1";
+ .port = "9080";
+ }
+ sub vcl_recv {
+ if (req.restarts > 0) {
+ set req.backend = good;
+ }
+ }
+ sub vcl_error {
+ if (req.restarts < 1) {
+ restart;
+ } else {
+ set obj.status = 201;
+ }
+ }
+ } -start
+
+client c1 {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 200
+} -run
+
Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h 2009-03-18 10:22:51 UTC (rev 3947)
+++ trunk/varnish-cache/include/vcl_returns.h 2009-03-18 11:25:43 UTC (rev 3948)
@@ -69,6 +69,7 @@
| (1 << VCL_RET_KEEP)
))
VCL_MET_MAC(error,ERROR,
- ((1 << VCL_RET_DELIVER)
+ ((1 << VCL_RET_RESTART)
+ | (1 << VCL_RET_DELIVER)
))
#endif
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-03-18 10:22:51 UTC (rev 3947)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2009-03-18 11:25:43 UTC (rev 3948)
@@ -44,7 +44,7 @@
{deliver {restart deliver}}
{timeout {fetch discard}}
{discard {discard keep}}
- {error {deliver}}
+ {error {restart deliver}}
}
# These are the return actions
More information about the varnish-commit
mailing list