[master] eae1571a6 PRIV_TASK vtc: make init/fini log order predictable & fix vtcs
Nils Goroll
nils.goroll at uplex.de
Tue Jan 12 16:39:07 UTC 2021
commit eae1571a693e22aa43815728dd2e1707919de2ae
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Jan 12 17:16:16 2021 +0100
PRIV_TASK vtc: make init/fini log order predictable & fix vtcs
Ref d89c8bf59b9da8263f1a767c68e4ee35d2569d11
diff --git a/bin/varnishtest/tests/r02451.vtc b/bin/varnishtest/tests/r02451.vtc
index 0dc0a5a4c..39cf67aa2 100644
--- a/bin/varnishtest/tests/r02451.vtc
+++ b/bin/varnishtest/tests/r02451.vtc
@@ -25,6 +25,7 @@ varnish v1 -vcl+backend {
new vd = directors.shard();
debug.test_priv_task("something");
debug.test_priv_task("to remember");
+ objx.test_priv_task(debug.test_priv_task());
vd.add_backend(s1);
vd.add_backend(s2);
@@ -44,8 +45,18 @@ varnish v1 -vcl+backend {
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
- expect 4 = VCL_Log {^func something to remember}
- expect 2 = VCL_Log {^obj something to remember}
+ expect 0 * Debug {^test_priv_task.*new}
+ expect 0 * Debug {^test_priv_task.*update}
+ expect 0 * Debug {^test_priv_task.*exists}
+ expect 0 * Debug {^objx.priv_task.*"something to remember".*new}
+ expect 0 * Debug {^test_priv_task.*exists}
+ expect 0 * VCL_Log {^func something to remember}
+ expect 0 * Debug {^objx.priv_task.*"something to remember".$}
+ expect 0 * VCL_Log {^obj something to remember}
+ expect 0 * Debug {^priv_task_free}
+ # string stored in obj priv_task has already been freed
+ expect 0 * Debug {^obj_priv_task_fini}
+ expect 0 * Debug {^vcl1: VCL_EVENT_WARM}
} -start
client c1 {
diff --git a/bin/varnishtest/tests/v00041.vtc b/bin/varnishtest/tests/v00041.vtc
index a01903b53..55415bd1d 100644
--- a/bin/varnishtest/tests/v00041.vtc
+++ b/bin/varnishtest/tests/v00041.vtc
@@ -149,9 +149,9 @@ logexpect l0 -v v1 -g raw -d 1 -q "vxid == 0 and not ExpKill" {
expect 0 = Debug {^test_priv_task.*new.$}
expect 0 = Debug {^test_priv_task.*update.$}
expect 0 = Debug {^test_priv_task.*exists.$}
+ expect 0 = Debug {^objc.priv_task.. = NULL}
expect 0 = Debug {^priv_task_free}
expect 0 = VCL_Log {^func cleaning up}
- expect 0 = Debug {^objc.priv_task.. = NULL}
expect 0 = VCL_Log {^obj }
expect 0 = CLI {^Wr 200 0 }
} -start
diff --git a/bin/varnishtest/tests/v00042.vtc b/bin/varnishtest/tests/v00042.vtc
index 54dcccaa0..b378a2731 100644
--- a/bin/varnishtest/tests/v00042.vtc
+++ b/bin/varnishtest/tests/v00042.vtc
@@ -42,6 +42,7 @@ varnish v1 -vcl+backend {
sub vcl_recv {
set req.http.x0 = debug.test_priv_task(req.url + req.esi_level);
+ o.test_priv_task(req.url + req.esi_level);
}
sub vcl_miss {
diff --git a/vmod/vmod_debug_obj.c b/vmod/vmod_debug_obj.c
index 8915402df..45f0a9d04 100644
--- a/vmod/vmod_debug_obj.c
+++ b/vmod/vmod_debug_obj.c
@@ -34,6 +34,7 @@
#include <string.h>
#include "cache/cache.h"
+#include "vcl.h"
#include "vcc_debug_if.h"
@@ -168,15 +169,23 @@ VCL_STRING v_matchproto_()
xyzzy_obj_test_priv_task(VRT_CTX, struct xyzzy_debug_obj *o, VCL_STRING s)
{
struct vmod_priv *p;
+ struct vsl_log *vsl;
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+
+ if (ctx->method & VCL_MET_TASK_H)
+ vsl = NULL;
+ else
+ vsl = ctx->vsl;
if (s == NULL || *s == '\0') {
p = VRT_priv_task_get(ctx, o);
if (p == NULL) {
- mylog(ctx->vsl, SLT_Debug, "%s.priv_task() = NULL",
+ mylog(vsl, SLT_Debug, "%s.priv_task() = NULL",
o->vcl_name);
return ("");
}
- mylog(ctx->vsl, SLT_Debug,
+ mylog(vsl, SLT_Debug,
"%s.priv_task() = %p .priv = %p (\"%s\")",
o->vcl_name, p, p->priv, p->priv);
return (p->priv);
@@ -185,13 +194,13 @@ xyzzy_obj_test_priv_task(VRT_CTX, struct xyzzy_debug_obj *o, VCL_STRING s)
p = VRT_priv_task(ctx, o);
if (p == NULL) {
- mylog(ctx->vsl, SLT_Debug, "%s.priv_task() = NULL [err]",
+ mylog(vsl, SLT_Debug, "%s.priv_task() = NULL [err]",
o->vcl_name);
VRT_fail(ctx, "no priv task - out of ws?");
return ("");
}
- mylog(ctx->vsl, SLT_Debug,
+ mylog(vsl, SLT_Debug,
"%s.priv_task() = %p .priv = %p (\"%s\") [%s]",
o->vcl_name, p, s, s, p->priv ? "update" : "new");
More information about the varnish-commit
mailing list