[4.1] 3885d2c Error earlier if we cannot find the probe
Lasse Karstensen
lkarsten at varnish-software.com
Thu Feb 11 17:14:32 CET 2016
commit 3885d2c8fe3d5edca729b607cafc224349208c86
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Tue Feb 2 08:04:20 2016 +0000
Error earlier if we cannot find the probe
We don't have forward declarations in VCL. OK'd by phk at .
Fixes #1837.
diff --git a/bin/varnishtest/tests/r01837.vtc b/bin/varnishtest/tests/r01837.vtc
new file mode 100644
index 0000000..4dc3d68
--- /dev/null
+++ b/bin/varnishtest/tests/r01837.vtc
@@ -0,0 +1,10 @@
+varnishtest "Test VCC errors out if probe is used before it is defined"
+
+varnish v1 -errvcl "Probe p not found" {
+ backend b {
+ .host = "127.0.0.1";
+ .probe = p;
+ }
+ probe p {
+ }
+}
diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc
index f7d4ed0..41626c1 100644
--- a/bin/varnishtest/tests/v00034.vtc
+++ b/bin/varnishtest/tests/v00034.vtc
@@ -20,7 +20,7 @@ varnish v1 -errvcl {Backend s1 redefined} {
}
varnish v1 -errvcl {Probe p1 redefined} {
- backend s1 { .host = "127.0.0.1"; .probe = p1;}
probe p1 { }
probe p1 { }
+ backend s1 { .host = "127.0.0.1"; .probe = p1;}
}
diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c
index 8a413c7..3260f65 100644
--- a/lib/libvcc/vcc_backend.c
+++ b/lib/libvcc/vcc_backend.c
@@ -384,6 +384,12 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
Fb(tl, 0, "\t.probe = &%s,\n", p);
ERRCHK(tl);
} else if (vcc_IdIs(t_field, "probe") && tl->t->tok == ID) {
+ if (VCC_FindSymbol(tl, tl->t, SYM_PROBE) == NULL) {
+ VSB_printf(tl->sb, "Probe %.*s not found\n",
+ PF(tl->t));
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
Fb(tl, 0, "\t.probe = &vgc_probe_%.*s,\n", PF(tl->t));
vcc_AddRef(tl, tl->t, SYM_PROBE);
vcc_NextToken(tl);
More information about the varnish-commit
mailing list