[master] cfdced3 Dump more VCL info in panic, and add a general macro for checking miniobj magics.
Poul-Henning Kamp
phk at FreeBSD.org
Wed May 4 15:04:06 CEST 2016
commit cfdced3e23e513c5d7db02f64001a2a990e28ce0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed May 4 13:02:58 2016 +0000
Dump more VCL info in panic, and add a general macro for checking
miniobj magics.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2b14c9b..a0d47ab 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1141,6 +1141,14 @@ DO_DEBUG(enum debug_bits x)
VSL(SLT_Debug, (id), __VA_ARGS__); \
} while (0)
+#define PAN_CheckMagic(vsb, ptr, exp) \
+ do { \
+ if ((ptr)->magic != (exp)) \
+ VSB_printf((vsb), \
+ "MAGIC 0x%08x (Should:%s/0x%08x)\n", \
+ (ptr)->magic, #exp, exp); \
+ } while(0)
+
#ifdef VARNISHD_IS_NOT_A_VMOD
# include "cache/cache_priv.h"
#endif
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index e0c5268..dc02731 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -142,6 +142,7 @@ pan_ws(struct vsb *vsb, const struct ws *ws)
if (pan_already(vsb, ws))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, ws, WS_MAGIC);
if (!(ws->id[0] & 0x20))
VSB_printf(vsb, "OVERFLOWED ");
VSB_printf(vsb, "id = \"%s\",\n", ws->id);
@@ -173,6 +174,7 @@ pan_htc(struct vsb *vsb, const struct http_conn *htc)
if (pan_already(vsb, htc))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, htc, HTTP_CONN_MAGIC);
VSB_printf(vsb, "fd = %d,\n", htc->fd);
VSB_printf(vsb, "doclose = %s,\n", sess_close_2str(htc->doclose, 0));
VSB_printf(vsb, "ws = %p,\n", htc->ws);
@@ -203,6 +205,7 @@ pan_http(struct vsb *vsb, const char *id, const struct http *h)
if (pan_already(vsb, h))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, h, HTTP_MAGIC);
VSB_printf(vsb, "ws[%s] = %p,\n", h->ws ? h->ws->id : "", h->ws);
VSB_printf(vsb, "hdrs {\n");
VSB_indent(vsb, 2);
@@ -226,6 +229,7 @@ pan_boc(struct vsb *vsb, const struct boc *boc)
if (pan_already(vsb, boc))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, boc, BOC_MAGIC);
VSB_printf(vsb, "refcnt = %u,\n", boc->refcount);
VSB_printf(vsb, "state = %d,\n", boc->state);
VSB_printf(vsb, "vary = %p,\n", boc->vary);
@@ -244,6 +248,7 @@ pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc)
if (pan_already(vsb, oc))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, oc, OBJCORE_MAGIC);
VSB_printf(vsb, "refcnt = %d,\n", oc->refcnt);
VSB_printf(vsb, "flags = 0x%x,\n", oc->flags);
VSB_printf(vsb, "exp_flags = 0x%x,\n", oc->exp_flags);
@@ -284,6 +289,7 @@ pan_wrk(struct vsb *vsb, const struct worker *wrk)
if (pan_already(vsb, wrk))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, wrk, WORKER_MAGIC);
VSB_printf(vsb, "stack = {0x%jx -> 0x%jx},\n",
(uintmax_t)wrk->stack_start, (uintmax_t)wrk->stack_end);
pan_ws(vsb, wrk->aws);
@@ -333,6 +339,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
if (pan_already(vsb, bo))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC);
pan_ws(vsb, bo->ws);
VSB_printf(vsb, "retries = %d, ", bo->retries);
VSB_printf(vsb, "failed = %d, ", bo->vfc->failed);
@@ -387,7 +394,7 @@ pan_req(struct vsb *vsb, const struct req *req)
if (pan_already(vsb, req))
return;
VSB_indent(vsb, 2);
-
+ PAN_CheckMagic(vsb, req, REQ_MAGIC);
xp = req->transport;
VSB_printf(vsb, "vxid = %u, transport = %s", VXID(req->vsl->wid),
xp == NULL ? "NULL" : xp->name);
@@ -467,6 +474,7 @@ pan_sess(struct vsb *vsb, const struct sess *sp)
if (pan_already(vsb, sp))
return;
VSB_indent(vsb, 2);
+ PAN_CheckMagic(vsb, sp, SESS_MAGIC);
xp = XPORT_ByNumber(sp->sattr[SA_TRANSPORT]);
VSB_printf(vsb, "fd = %d, vxid = %u,\n",
sp->fd, VXID(sp->vxid));
diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h
index 47330ee..415822c 100644
--- a/bin/varnishd/cache/cache_priv.h
+++ b/bin/varnishd/cache/cache_priv.h
@@ -57,7 +57,6 @@ void BAN_NewObjCore(struct objcore *oc);
void BAN_DestroyObj(struct objcore *oc);
int BAN_CheckObject(struct worker *, struct objcore *, struct req *);
-
/* cache_busyobj.c */
void VBO_Init(void);
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 6da6ebd..0dcaa73 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -98,10 +98,17 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl)
return;
VSB_printf(vsb, "vcl = {\n");
VSB_indent(vsb, 2);
- VSB_printf(vsb, "temp = %s\n", vcl->temp);
+ PAN_CheckMagic(vsb, vcl, VCL_MAGIC);
+ VSB_printf(vsb, "busy = %u\n", vcl->busy);
+ VSB_printf(vsb, "discard = %u,\n", vcl->discard);
+ VSB_printf(vsb, "state = %s,\n", vcl->state);
+ VSB_printf(vsb, "temp = %s,\n", vcl->temp);
+ VSB_printf(vsb, "conf = {\n");
+ VSB_indent(vsb, 2);
if (vcl->conf == NULL) {
VSB_printf(vsb, "conf = NULL\n");
} else {
+ PAN_CheckMagic(vsb, vcl->conf, VCL_CONF_MAGIC);
VSB_printf(vsb, "srcname = {\n");
VSB_indent(vsb, 2);
for (i = 0; i < vcl->conf->nsrc; ++i)
@@ -111,6 +118,8 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl)
}
VSB_indent(vsb, -2);
VSB_printf(vsb, "},\n");
+ VSB_indent(vsb, -2);
+ VSB_printf(vsb, "},\n");
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list