[master] 1952d3c9a vmod_debug: make $Method obj.test_priv_top() per-instance
Nils Goroll
nils.goroll at uplex.de
Wed Jan 13 09:59:06 UTC 2021
commit 1952d3c9ac2ea411328a0382fe2e1a2426491357
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Jan 13 10:40:02 2021 +0100
vmod_debug: make $Method obj.test_priv_top() per-instance
Use a per-instance PRIV_TOP for the oo based test
diff --git a/bin/varnishtest/tests/v00043.vtc b/bin/varnishtest/tests/v00043.vtc
index 9aaae1aac..8933aa5ba 100644
--- a/bin/varnishtest/tests/v00043.vtc
+++ b/bin/varnishtest/tests/v00043.vtc
@@ -44,6 +44,7 @@ varnish v1 -cliok "param.set debug +syncvsl" -vcl+backend {
sub vcl_recv {
set req.http.x0 = debug.test_priv_top(req.url + req.esi_level);
+ o.test_priv_top(req.url + req.esi_level);
}
sub vcl_miss {
diff --git a/vmod/vmod_debug.vcc b/vmod/vmod_debug.vcc
index a787bb2c8..d085d797f 100644
--- a/vmod/vmod_debug.vcc
+++ b/vmod/vmod_debug.vcc
@@ -116,7 +116,9 @@ $Method STRING .test_priv_task(STRING s="")
Test per-object priv_task via VRT_priv_task() / VRT_priv_get()
-$Method STRING .test_priv_top(PRIV_TOP, STRING)
+$Method STRING .test_priv_top(STRING s="")
+
+Test per-object priv_top via VRT_priv_top()
$Function VOID rot52(HTTP hdr)
diff --git a/vmod/vmod_debug_obj.c b/vmod/vmod_debug_obj.c
index d6db70ff4..61dc8a454 100644
--- a/vmod/vmod_debug_obj.c
+++ b/vmod/vmod_debug_obj.c
@@ -211,12 +211,30 @@ xyzzy_obj_test_priv_task(VRT_CTX, struct xyzzy_debug_obj *o, VCL_STRING s)
return (p->priv);
}
+static const struct vmod_priv_methods xyzzy_obj_test_priv_top_methods[1] = {{
+ .magic = VMOD_PRIV_METHODS_MAGIC,
+ .type = "debug_obj_test_priv_top",
+ .fini = free
+}};
+
VCL_STRING v_matchproto_()
-xyzzy_obj_test_priv_top(VRT_CTX,
- struct xyzzy_debug_obj *o, struct vmod_priv *priv, VCL_STRING s)
+xyzzy_obj_test_priv_top(VRT_CTX, struct xyzzy_debug_obj *o, VCL_STRING s)
{
- (void)o;
- return (xyzzy_test_priv_top(ctx, priv, s));
+ struct vmod_priv *p;
+
+ p = VRT_priv_top(ctx, o);
+
+ if (p == NULL) {
+ VRT_fail(ctx, "no priv task - out of ws?");
+ return ("");
+ }
+
+ if (p->priv == NULL) {
+ p->priv = strdup(s);
+ p->methods = xyzzy_obj_test_priv_top_methods;
+ }
+ assert (p->methods == xyzzy_obj_test_priv_top_methods);
+ return (p->priv);
}
/* ----------------------------------------------------------------------------
More information about the varnish-commit
mailing list