r5457 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl
phk at varnish-cache.org
phk at varnish-cache.org
Fri Oct 22 12:29:17 CEST 2010
Author: phk
Date: 2010-10-22 12:29:17 +0200 (Fri, 22 Oct 2010)
New Revision: 5457
Added:
trunk/varnish-cache/bin/varnishtest/tests/v00031.vtc
Modified:
trunk/varnish-cache/bin/varnishd/mgt.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/include/libvcl.h
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_compile.h
trunk/varnish-cache/lib/libvcl/vcc_xref.c
Log:
Add a parameter "vcc_err_unref" which controls if unreferenced
VCL objects (ACL, backend, subroutine etc) are errors or warnings.
Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h 2010-10-22 10:00:55 UTC (rev 5456)
+++ trunk/varnish-cache/bin/varnishd/mgt.h 2010-10-22 10:29:17 UTC (rev 5457)
@@ -83,8 +83,8 @@
extern char *mgt_cc_cmd;
extern char *mgt_vcl_dir;
extern char *mgt_vmod_dir;
+extern unsigned mgt_vcc_err_unref;
-
#define REPORT0(pri, fmt) \
do { \
fprintf(stderr, fmt "\n"); \
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-10-22 10:00:55 UTC (rev 5456)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-10-22 10:29:17 UTC (rev 5457)
@@ -832,6 +832,10 @@
".",
#endif
NULL },
+ { "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref, 0, 0,
+ "Unreferenced VCL objects result in error.\n",
+ 0,
+ "on", "bool" },
{ NULL, NULL, NULL }
};
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2010-10-22 10:00:55 UTC (rev 5456)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2010-10-22 10:29:17 UTC (rev 5457)
@@ -69,6 +69,7 @@
char *mgt_cc_cmd;
char *mgt_vcl_dir;
char *mgt_vmod_dir;
+unsigned mgt_vcc_err_unref;
static struct vcc *vcc;
@@ -146,6 +147,7 @@
XXXAN(sb);
VCC_VCL_dir(vcc, mgt_vcl_dir);
VCC_VMOD_dir(vcc, mgt_vmod_dir);
+ VCC_Err_Unref(vcc, mgt_vcc_err_unref);
csrc = VCC_Compile(vcc, sb, vp->vcl);
vsb_finish(sb);
AZ(vsb_overflowed(sb));
Added: trunk/varnish-cache/bin/varnishtest/tests/v00031.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00031.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00031.vtc 2010-10-22 10:29:17 UTC (rev 5457)
@@ -0,0 +1,23 @@
+# $Id$
+
+test "param vcc_err_unref"
+
+varnish v1 -badvcl {
+ backend b { .host = "127.0.0.1"; }
+ backend c { .host = "127.0.0.1"; }
+}
+
+varnish v1 -cliok "param.set vcc_err_unref false"
+
+varnish v1 -vcl {
+ backend b { .host = "127.0.0.1"; }
+ backend c { .host = "127.0.0.1"; }
+}
+
+varnish v1 -cliok "param.set vcc_err_unref true"
+
+varnish v1 -badvcl {
+ backend b { .host = "127.0.0.1"; }
+ backend c { .host = "127.0.0.1"; }
+}
+
Modified: trunk/varnish-cache/include/libvcl.h
===================================================================
--- trunk/varnish-cache/include/libvcl.h 2010-10-22 10:00:55 UTC (rev 5456)
+++ trunk/varnish-cache/include/libvcl.h 2010-10-22 10:29:17 UTC (rev 5457)
@@ -35,6 +35,7 @@
void VCC_Default_VCL(struct vcc *, const char *str);
void VCC_VCL_dir(struct vcc *, const char *str);
void VCC_VMOD_dir(struct vcc *, const char *str);
+void VCC_Err_Unref(struct vcc *tl, unsigned u);
char *VCC_Compile(const struct vcc *, struct vsb *sb, const char *b);
const char *VCC_Return_Name(unsigned action);
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2010-10-22 10:00:55 UTC (rev 5456)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2010-10-22 10:29:17 UTC (rev 5457)
@@ -472,6 +472,9 @@
REPLACE(tl->default_vcl, tl0->default_vcl);
REPLACE(tl->vcl_dir, tl0->vcl_dir);
tl->vars = tl0->vars;
+ tl->err_unref = tl0->err_unref;
+ } else {
+ tl->err_unref = 1;
}
VTAILQ_INIT(&tl->symbols);
VTAILQ_INIT(&tl->hosts);
@@ -753,3 +756,16 @@
CHECK_OBJ_NOTNULL(tl, VCC_MAGIC);
REPLACE(tl->vmod_dir, str);
}
+
+/*--------------------------------------------------------------------
+ * Configure default
+ */
+
+void
+VCC_Err_Unref(struct vcc *tl, unsigned u)
+{
+
+ CHECK_OBJ_NOTNULL(tl, VCC_MAGIC);
+ printf("EU= %u\n", u);
+ tl->err_unref = u;
+}
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-10-22 10:00:55 UTC (rev 5456)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-10-22 10:29:17 UTC (rev 5457)
@@ -152,6 +152,8 @@
unsigned recnt;
unsigned nsockaddr;
unsigned nvmodpriv;
+
+ unsigned err_unref;
};
struct var {
Modified: trunk/varnish-cache/lib/libvcl/vcc_xref.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_xref.c 2010-10-22 10:00:55 UTC (rev 5456)
+++ trunk/varnish-cache/lib/libvcl/vcc_xref.c 2010-10-22 10:29:17 UTC (rev 5457)
@@ -114,6 +114,10 @@
vsb_printf(tl->sb, "Unused %s %.*s, defined:\n",
VCC_SymKind(tl, sym), PF(sym->def_b));
vcc_ErrWhere(tl, sym->def_b);
+ if (!tl->err_unref) {
+ vsb_printf(tl->sb, "(That was just a warning)\n");
+ tl->err = 0;
+ }
}
}
More information about the varnish-commit
mailing list