r2480 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Fri Feb 15 13:44:42 CET 2008


Author: phk
Date: 2008-02-15 13:44:42 +0100 (Fri, 15 Feb 2008)
New Revision: 2480

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_backend.c
Log:
Insist on a non-zero weight for random director memebers and 


Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2008-02-15 12:42:48 UTC (rev 2479)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2008-02-15 12:44:42 UTC (rev 2480)
@@ -385,12 +385,13 @@
 	struct token *t_field;
 	int nbh, nelem;
 	struct fld_spec *fs;
+	unsigned u;
 
 	Fh(tl, 1, "\n#define VGC_backend_%.*s (VCL_conf.director[%d])\n",
 	    PF(t_dir), tl->nbackend);
 	vcc_AddDef(tl, t_dir, R_BACKEND);
 
-	fs = vcc_FldSpec(tl, "!backend", "?weight", NULL);
+	fs = vcc_FldSpec(tl, "!backend", "!weight", NULL);
 
 	vcc_NextToken(tl);		/* ID: policy (= random) */
 
@@ -418,7 +419,16 @@
 				ERRCHK(tl);
 			} else if (vcc_IdIs(t_field, "weight")) {
 				ExpectErr(tl, CNUM);
-				Fc(tl, 0, " .weight = %.*s,", PF(tl->t));
+				u = vcc_UintVal(tl);
+				if (u == 0) {
+					vsb_printf(tl->sb,
+					    "The .weight must be higher than zero.");
+					vcc_ErrToken(tl, tl->t);
+					vsb_printf(tl->sb, " at\n");
+					vcc_ErrWhere(tl, tl->t);
+					return;
+				}
+				Fc(tl, 0, " .weight = %u", u);
 				vcc_NextToken(tl);
 				ExpectErr(tl, ';');
 				vcc_NextToken(tl);




More information about the varnish-commit mailing list