
varnish-bugs at varnish-cache
Aug 6, 2013, 6:20 AM
Post #1 of 1
(15 views)
Permalink
|
|
#1332: ENUM in Object member method hides subsequent methods
|
|
#1332: ENUM in Object member method hides subsequent methods ---------------------------+-------------------- Reporter: jw | Type: defect Status: new | Priority: normal Milestone: | Component: build Version: trunk | Severity: normal Keywords: vmod VCL_ENUM | ---------------------------+-------------------- When an object contains a method that takes an ENUM as arguments, methods after the enums can not be reached in VCL. Consider the following vmod.vcc: {{{ Module etest Object etest() { Method VOID .bar(ENUM { AA, BB, CC, DD }) Method VOID .foo() } }}} foo becomes invisible the the VCL compiler: {{{ backend default { .host = "127.0.0.1"; .port = "80"; } backend b1 { .host = "192.168.100.11"; .port = "8000"; } import etest; sub vcl_init { new et = etest.etest(); } sub vcl_recv { et.foo(); et.bar(AA); set req.backend = b1; } }}} {{{ ./sbin/varnishd -a 127.0.0.1:8080 -d -f ./etc/varnish/default.vcl -C Message from VCC-compiler: Not running as root, no priv-sep Expected an action, 'if', '{' or '}' ('input' Line 19 Pos 9) et.foo(); --------######--- }}} Switching the position of foo and bar in vmod.vcc "solves" the issue, as there is no method after. The reason seems to be, that ENUM ends with \0\0, plus a third \0 for the Method ends appears as \0\0\0 just as the end of the Object definition. const char * const Vmod_etest_Spec[] = { /* Object etest */ "OBJ\0" "etest.etest\0Vmod_etest_Func.etest__init\0VOID\0\0" "struct vmod_etest_etest\0" "etest.etest\0Vmod_etest_Func.etest__fini\0VOID\0\0" "etest.etest.bar\0Vmod_etest_Func.etest_bar\0VOID\0ENUM\0AA\0BB\0CC\0DD\0\0\0" "etest.etest.foo\0Vmod_etest_Func.etest_foo\0VOID\0\0" "\0", /* Functions */ /* Init/Fini */ 0 }; Just for the case you want to reproduce: etest.c {{{ #include <stdlib.h> #include "vrt.h" #include "cache/cache.h" #include "vcc_if.h" struct vmod_etest_etest { unsigned magic; //needed #define VMOD_ETEST_ETEST_MAGIC 0x9454a5ce }; VCL_VOID __match_proto__(td_etest_etest__init) vmod_etest__init(const struct vrt_ctx *ctx, struct vmod_etest_etest **etestp, const char *vcl_name) { struct vmod_etest_etest *etest; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(etestp); AZ(*etestp); ALLOC_OBJ(etest, VMOD_ETEST_ETEST_MAGIC); AN(etest); *etestp = etest; } VCL_VOID __match_proto__(td_etest_etest__fini) vmod_etest__fini(struct vmod_etest_etest **etestp) { struct vmod_etest_etest *etest; etest = *etestp; *etestp = NULL; CHECK_OBJ_NOTNULL(etest, VMOD_ETEST_ETEST_MAGIC); FREE_OBJ(etest); } VCL_VOID __match_proto__(td_etest_etest_foo) vmod_etest_foo(const struct vrt_ctx *ctx, struct vmod_etest_etest *etest) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(etest, VMOD_ETEST_ETEST_MAGIC); txt t; char *msg = "DEBUG etest.foo()"; t.b = msg; t.e = msg + strlen(msg); VSLbt(ctx->vsl, SLT_Debug, t); } VCL_VOID __match_proto__(td_etest_etest_bar) vmod_etest_bar(const struct vrt_ctx *ctx, struct vmod_etest_etest *etest, VCL_ENUM e) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(etest, VMOD_ETEST_ETEST_MAGIC); txt t; char *msg = "DEBUG etest.bar()"; t.b = msg; t.e = msg + strlen(msg); VSLbt(ctx->vsl, SLT_Debug, t); } }}} -- Ticket URL: <https://www.varnish-cache.org/trac/ticket/1332> Varnish <https://varnish-cache.org/> The Varnish HTTP Accelerator _______________________________________________ varnish-bugs mailing list varnish-bugs [at] varnish-cache https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
|