Commit 26ed0496 authored by Kristian Lyngstøl's avatar Kristian Lyngstøl

Allow restart in vcl_error


git-svn-id: http://www.varnish-cache.org/svn/trunk@3948 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0b1f97af
......@@ -306,10 +306,6 @@ cnt_error(struct sess *sp)
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 @@ cnt_error(struct sess *sp)
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;
......
# $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
......@@ -69,6 +69,7 @@ VCL_MET_MAC(discard,DISCARD,
| (1 << VCL_RET_KEEP)
))
VCL_MET_MAC(error,ERROR,
((1 << VCL_RET_DELIVER)
((1 << VCL_RET_RESTART)
| (1 << VCL_RET_DELIVER)
))
#endif
......@@ -44,7 +44,7 @@ set methods {
{deliver {restart deliver}}
{timeout {fetch discard}}
{discard {discard keep}}
{error {deliver}}
{error {restart deliver}}
}
# These are the return actions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment