[master] 9962996 Fix an issue where the order of symbol definition determined if code could compile or not.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Aug 27 09:30:34 CEST 2014
commit 996299655c9ed5d94853a495ddaa2ae29094a9e9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Aug 27 07:29:49 2014 +0000
Fix an issue where the order of symbol definition determined if
code could compile or not.
Fixes #1569
diff --git a/bin/varnishtest/tests/r01569.vtc b/bin/varnishtest/tests/r01569.vtc
new file mode 100644
index 0000000..7a05938
--- /dev/null
+++ b/bin/varnishtest/tests/r01569.vtc
@@ -0,0 +1,19 @@
+varnishtest "symbol lookup order issue"
+
+varnish v1 -vcl {
+ vcl 4.0;
+ import ${vmod_debug};
+
+ backend debug {
+ .host = "127.0.0.1";
+ .port = "80";
+ }
+
+ sub debug {
+ set req.backend_hint = debug;
+ }
+
+ sub vcl_recv {
+ call debug;
+ }
+}
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index c6c75fe..3557a4b 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -688,7 +688,15 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
* XXX: what if var and func/proc had same name ?
* XXX: look for SYM_VAR first for consistency ?
*/
- sym = VCC_FindSymbol(tl, tl->t, SYM_NONE);
+ sym = NULL;
+ if (fmt == BACKEND)
+ sym = VCC_FindSymbol(tl, tl->t, SYM_BACKEND);
+ if (sym == NULL)
+ sym = VCC_FindSymbol(tl, tl->t, SYM_VAR);
+ if (sym == NULL)
+ sym = VCC_FindSymbol(tl, tl->t, SYM_FUNC);
+ if (sym == NULL)
+ sym = VCC_FindSymbol(tl, tl->t, SYM_NONE);
if (sym == NULL || sym->eval == NULL) {
VSB_printf(tl->sb, "Symbol not found: ");
vcc_ErrToken(tl, tl->t);
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index c3d8a13..e9d39f0 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -50,7 +50,6 @@ VCC_SymKind(struct vcc *tl, const struct symbol *s)
}
}
-
static struct symbol *
vcc_AddSymbol(struct vcc *tl, const char *nb, int l, enum symkind kind)
{
More information about the varnish-commit
mailing list