Commit 1b4314e1 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r3948: Allow restart in vcl_error



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@3991 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e56c5d2b
......@@ -305,10 +305,6 @@ cnt_error(struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->bereq);
/* 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
......@@ -73,6 +73,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
......@@ -324,9 +324,9 @@ vcl_output_lang_h(struct vsb *sb)
/* ../../include/vrt_obj.h */
vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3616 2009-02-05 11:43:20Z ");
vsb_cat(sb, "tfheen $\n *\n * NB: This file is machine generated, ");
vsb_cat(sb, "DO NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, "/*\n * $Id: vrt_obj.h 3990 2009-03-23 12:37:42Z tfheen");
vsb_cat(sb, " $\n *\n * NB: This file is machine generated, DO NOT");
vsb_cat(sb, " EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
vsb_cat(sb, "s *);\nconst char * VRT_r_server_hostname(struct sess ");
......
......@@ -45,7 +45,7 @@ set methods {
{prefetch {fetch pass}}
{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