Open stevendore opened 6 days ago
bugwash: I will look and ask @walid-git for a review when I have a PR
@walid-git @dridi I'd like to ask for your advice here: The problem is that the default
backend does not have a symbol, and before we let this special casing proliferate more, I wonder if it could the be better option to have more than one "special" symbol named default
, one for each kind ?
Why not add a can_default
flag to struct type
and raise it only for BACKEND
and PROBE
to have this special casing "generalized"? The symbol table could back this pseudo-symbol with an actual struct symbol
.
I worry about allowing any type to overload a new symbol that comes with special properties for the types where this pseudo-symbol is currently allowed.
I gave this a try, but the fundamental problem seems to be that currently the vcc symbol code does not take into account multiple symbols by the same name and different types.
I gave it a try myself and came up with a minimal fix:
--- i/lib/libvcc/vcc_backend.c
+++ w/lib/libvcc/vcc_backend.c
@@ -732,7 +732,9 @@ vcc_ParseBackend(struct vcc *tl)
vcc_ErrWhere(tl, t_first);
return;
}
- vcc_NextToken(tl);
+ sym = VCC_SymbolGet(tl, SYM_MAIN, SYM_FUNC, SYMTAB_EXISTING,
+ XREF_NONE);
+ AN(sym);
dn = "vgc_backend_default";
tl->default_director = dn;
} else {
Since the "default" pseudo symbol can evaluate to either PROBE
or BACKEND
, my suggestion would be to add an internal DEFAULT
type for the symbol to deal with the exceptional dual-typing. We could also wrap the VCC_SymbolGet()
above with a new dedicated function, VCC_SymbolDefault()
for example.
Thoughts?
I gave it a try myself and came up with a minimal fix:
WOW, I am impressed.
--- i/lib/libvcc/vcc_backend.c +++ w/lib/libvcc/vcc_backend.c @@ -732,7 +732,9 @@ vcc_ParseBackend(struct vcc *tl) vcc_ErrWhere(tl, t_first); return; } - vcc_NextToken(tl); + sym = VCC_SymbolGet(tl, SYM_MAIN, SYM_FUNC, SYMTAB_EXISTING, + XREF_NONE);
I do not understand why SYM_FUNC
and not SYM_BACKEND
, could you explain? Really this is not a rhetorical question, I would really like to know
BTW, so you know more about my struggle, here are my attempts which I had meant to link to earlier: https://github.com/nigoroll/varnish-cache/tree/TRY_4177_vcc_default_backend
I do not understand why
SYM_FUNC
and notSYM_BACKEND
, could you explain?
default
is a pseudo symbol that may resolve (with an eval function) to either a PROBE
or a BACKEND
. It does have the type BACKEND
under the hood, but that is inaccurate and mostly a play-pretend type.
I think I will submit a some kind of all-of-the-above patch series with this fix and the other suggestions I made.
Expected Behavior
backend default
to be allowed to usevia
backends.Current Behavior
Panic on VCL compilation:
Possible Solution
No response
Steps to Reproduce (for bugs)
Using c42.vtc as an example, changing the name of s2 to default results in a VCC panic. https://github.com/varnishcache/varnish-cache/blob/master/bin/varnishtest/tests/c00042.vtc#L51
Context
Using a proxy on backend with only one backend.
Varnish Cache version
varnish trunk, varnish 7.5
Operating system
No response
Source of binary packages used (if any)
No response