[master] 6002065 Improve panic reporting of VCL methods: a '*' indicates that we are currently in the method.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Jul 29 19:34:04 CEST 2014
commit 60020658a83bd6d55dea1b307efd085b6ac57c68
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jul 29 17:33:20 2014 +0000
Improve panic reporting of VCL methods:
a '*' indicates that we are currently in the method.
Also add a list of methods we have previously called.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f711959..315ec4c 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -332,6 +332,7 @@ struct worker {
struct vxid_pool vxid_pool;
unsigned cur_method;
+ unsigned seen_methods;
unsigned handling;
};
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 4e11fe6..9b9a7a9 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -268,21 +268,42 @@ static void
pan_wrk(const struct worker *wrk)
{
const char *hand;
+ unsigned m, u;
+ const char *p;
VSB_printf(pan_vsp, " worker = %p {\n", wrk);
pan_ws(wrk->aws, 4);
- hand = VCL_Method_Name(wrk->cur_method);
+ m = wrk->cur_method;
+ VSB_printf(pan_vsp, " VCL::method = ");
+ if (m == 0) {
+ VSB_printf(pan_vsp, "none,\n");
+ return;
+ }
+ if (!(m & 1))
+ VSB_printf(pan_vsp, "*");
+ m &= ~1;
+ hand = VCL_Method_Name(m);
if (hand != NULL)
- VSB_printf(pan_vsp, " VCL::method = %s,\n", hand);
+ VSB_printf(pan_vsp, "%s,\n", hand);
else
- VSB_printf(pan_vsp, " VCL::method = 0x%x,\n", wrk->cur_method);
+ VSB_printf(pan_vsp, "0x%x,\n", m);
hand = VCL_Return_Name(wrk->handling);
if (hand != NULL)
VSB_printf(pan_vsp, " VCL::return = %s,\n", hand);
else
VSB_printf(pan_vsp, " VCL::return = 0x%x,\n", wrk->handling);
- VSB_printf(pan_vsp, " },\n");
+ VSB_printf(pan_vsp, " VCL::methods = {");
+ m = wrk->seen_methods;
+ p = "";
+ for (u = 1; m ; u <<= 1) {
+ if (m & u) {
+ VSB_printf(pan_vsp, "%s%s", p, VCL_Method_Name(u));
+ m &= ~u;
+ p = ", ";
+ }
+ }
+ VSB_printf(pan_vsp, "},\n },\n");
}
static void
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 1678ea3..7e48a86 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -450,11 +450,12 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
aws = WS_Snapshot(wrk->aws);
wrk->handling = 0;
wrk->cur_method = method;
+ wrk->seen_methods |= method;
AN(vsl);
VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method));
(void)func(&ctx);
VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling));
- wrk->cur_method = 0;
+ wrk->cur_method |= 1; // Magic marker
/*
* VCL/Vmods are not allowed to make permanent allocations from
More information about the varnish-commit
mailing list