Commit 2203ab28 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make "rollback" its own action, it can be used anywhere.

Make "restart" require "return(restart)" like all other terminating actions.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4652 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent efe03fa1
# $Id$
test "Test Rollback"
server s1 {
rxreq
expect req.url == "/foo"
expect req.http.foobar == "harck-coff"
txresp -status 400
rxreq
expect req.url == "/bar"
expect req.http.foobar == "snark"
txresp -bodylen 5
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.url == "/foo") {
set req.http.foobar = "harck-coff";
}
}
sub vcl_fetch {
if (beresp.status == 400) {
rollback;
set req.url = "/bar";
return (restart);
}
}
} -start
client c1 {
txreq -url "/foo" -hdr "foobar: snark"
rxresp
} -run
......@@ -4,13 +4,8 @@ test "VCL compiler coverage test: vcc_action.c"
varnish v1 -vcl {
backend b { .host = "127.0.0.1"; }
sub vcl_hit { restart ; }
sub vcl_miss { restart rollback; }
}
varnish v1 -badvcl {
backend b { .host = "127.0.0.1"; }
sub vcl_hit { restart 2 ; }
sub vcl_hit { return (restart) ; }
sub vcl_miss { rollback; return (restart); }
}
varnish v1 -vcl {
......
......@@ -46,27 +46,6 @@ SVNID("$Id$")
/*--------------------------------------------------------------------*/
static void
parse_restart(struct tokenlist *tl)
{
struct token *t1;
t1 = VTAILQ_NEXT(tl->t, list);
if (t1->tok == ID && vcc_IdIs(t1, "rollback")) {
Fb(tl, 1, "VRT_Rollback(sp);\n");
vcc_NextToken(tl);
} else if (t1->tok != ';') {
vsb_printf(tl->sb, "Expected \"rollback\" or semicolon.\n");
vcc_ErrWhere(tl, t1);
ERRCHK(tl);
}
Fb(tl, 1, "VRT_done(sp, VCL_RET_RESTART);\n");
vcc_ProcAction(tl->curproc, VCL_RET_RESTART, tl->t);
vcc_NextToken(tl);
}
/*--------------------------------------------------------------------*/
static void
parse_call(struct tokenlist *tl)
{
......@@ -239,11 +218,6 @@ parse_set(struct tokenlist *tl)
return;
}
Fb(tl, 0, ");\n");
/*
* We count the number of operations on the req.hash
* variable, so that varnishd can preallocate the worst case
* number of slots for composing the hash string.
*/
break;
case STRING:
if (tl->t->tok != '=') {
......@@ -442,6 +416,17 @@ parse_esi(struct tokenlist *tl)
/*--------------------------------------------------------------------*/
static void
parse_new_syntax(struct tokenlist *tl)
{
vsb_printf(tl->sb, "Please change \"%.*s\" to \"return(%.*s)\".\n",
PF(tl->t), PF(tl->t));
vcc_ErrWhere(tl, tl->t);
}
/*--------------------------------------------------------------------*/
static void
parse_panic(struct tokenlist *tl)
{
......@@ -510,24 +495,12 @@ parse_synthetic(struct tokenlist *tl)
/*--------------------------------------------------------------------*/
static void
parse_new_syntax(struct tokenlist *tl)
{
vsb_printf(tl->sb, "Please change \"%.*s\" to \"return(%.*s)\".\n",
PF(tl->t), PF(tl->t));
vcc_ErrWhere(tl, tl->t);
}
/*--------------------------------------------------------------------*/
typedef void action_f(struct tokenlist *tl);
static struct action_table {
const char *name;
action_f *func;
} action_table[] = {
{ "restart", parse_restart },
{ "error", parse_error },
#define VCL_RET_MAC(l, U) \
......@@ -542,10 +515,11 @@ static struct action_table {
{ "purge", parse_purge },
{ "purge_url", parse_purge_url },
{ "remove", parse_unset }, /* backward compatibility */
{ "return", parse_return },
{ "rollback", parse_rollback },
{ "set", parse_set },
{ "synthetic", parse_synthetic },
{ "unset", parse_unset },
{ "return", parse_return },
{ NULL, NULL }
};
......
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