Mailing List Archive

r3246 - trunk/varnish-cache/lib/libvcl
Author: phk
Date: 2008-10-05 12:31:23 +0200 (Sun, 05 Oct 2008)
New Revision: 3246

Modified:
trunk/varnish-cache/lib/libvcl/vcc_parse.c
Log:
Make it possible to say:

if (req.backend == b1)

in VCL.



Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_parse.c 2008-10-05 10:23:12 UTC (rev 3245)
+++ trunk/varnish-cache/lib/libvcl/vcc_parse.c 2008-10-05 10:31:23 UTC (rev 3246)
@@ -322,10 +322,29 @@
}

static void
-Cond_Backend(const struct var *vp, const struct tokenlist *tl)
+Cond_Backend(const struct var *vp, struct tokenlist *tl)
{

Fb(tl, 1, "%s\n", vp->rname);
+ if (tl->t->tok == T_EQ) {
+ Fb(tl, 1, " ==\n");
+ } else if (tl->t->tok == T_NEQ) {
+ Fb(tl, 1, " !=\n");
+ } else {
+ vsb_printf(tl->sb, "Invalid condition ");
+ vcc_ErrToken(tl, tl->t);
+ vsb_printf(tl->sb, " on backend variable\n");
+ vsb_printf(tl->sb,
+ " only '==' and '!=' are legal\n");
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
+ vcc_NextToken(tl);
+ vcc_ExpectCid(tl);
+ ERRCHK(tl);
+ vcc_AddRef(tl, tl->t, R_BACKEND);
+ Fb(tl, 1, "VGC_backend_%.*s\n", PF(tl->t));
+ vcc_NextToken(tl);
}

static void