Hi phk, Now that we expose the panic functions also to vmods, I believe we need to define a somewhat cleaner way for different parts to produce the panic output. It's the indentation and how that's hard coded into each panic generator that's the major issue in my opinion, e.g. how the panic handler in the backend vmod would have to now to insert 4 character whitespace on each line in order to match it with where it's output would probably go in the panic string.
The attached patch series changes this. It's a lot of patches, as it changes all of the panic code slightly. First one shows the utility functions I created for this purpose, and the rest are patches for different panic string generators. Martin -- <http://varnish-software.com>*Martin Blix Grydeland* Senior Developer | Varnish Software AS Mobile: +47 992 74 756 We Make Websites Fly!
From 55b9b77600f8038daf3901ba441365b7351f7c44 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 11:42:32 +0200 Subject: [PATCH 01/16] Panic utility functions --- bin/varnishd/cache/cache_panic.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/Makefile.am | 3 ++- include/pan.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 include/pan.h diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index bfe3e70..a7688f0 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -48,6 +48,7 @@ #include "cache_director.h" #include "storage/storage.h" #include "vcli_priv.h" +#include "pan.h" /* * The panic string is constructed in memory, then copied to the @@ -580,6 +581,45 @@ static struct cli_proto debug_cmds[] = { /*--------------------------------------------------------------------*/ +/* + * Print pan->indent number of whitespace characters to pan->vsb + */ +void +PAN_indent(struct pan *pan) +{ + (void)VSB_printf(pan->vsb, "%*s", pan->indent, ""); +} + +/* + * Print the formated string to the panic string buffer + */ +void +PAN_printf(struct pan *pan, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + (void)VSB_vprintf(pan->vsb, format, ap); + va_end(ap); +} + +/* + * Indent, then print the formated line followed by a newline + */ +void +PAN_linef(struct pan *pan, const char *format, ...) +{ + va_list ap; + + PAN_indent(pan); + va_start(ap, format); + (void)VSB_vprintf(pan->vsb, format, ap); + va_end(ap); + (void)VSB_printf(pan->vsb, "\n"); +} + +/*--------------------------------------------------------------------*/ + void PAN_Init(void) { diff --git a/include/Makefile.am b/include/Makefile.am index 2d4593e..02d3e8b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -57,7 +57,8 @@ nobase_pkginclude_HEADERS += \ vrt_obj.h \ vsa.h \ vsb.h \ - vsha256.h + vsha256.h \ + pan.h # Private headers nobase_noinst_HEADERS = \ diff --git a/include/pan.h b/include/pan.h new file mode 100644 index 0000000..88868c6 --- /dev/null +++ b/include/pan.h @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2015 Varnish Software AS + * All rights reserved. + * + * Author: Martin Blix Grydeland <[email protected]> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define PAN_IND 2 /* Indentation width */ + +struct pan { + int indent; + struct vsb *vsb; +}; + +void PAN_indent(struct pan *); +void PAN_printf(struct pan *, const char *, ...) __v_printflike(2, 3); +void PAN_linef(struct pan *, const char *, ...) __v_printflike(2, 3); -- 2.1.4
From ba0c809f5baf69c0ecac5eacceff81ba392a109b Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 11:56:41 +0200 Subject: [PATCH 02/16] Change pan_ic to use new panic --- bin/varnishd/cache/cache_panic.c | 43 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index a7688f0..69bad29 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -477,6 +477,7 @@ static void __attribute__((__noreturn__)) pan_ic(const char *func, const char *file, int line, const char *cond, enum vas_e kind) { + struct pan pan[1]; const char *q; struct req *req; struct busyobj *bo; @@ -496,44 +497,44 @@ pan_ic(const char *func, const char *file, int line, const char *cond, sa.sa_handler = SIG_DFL; (void)sigaction(SIGSEGV, &sa, NULL); + pan->vsb = &pan_vsp_storage; + pan->indent = 0; + switch(kind) { case VAS_WRONG: - VSB_printf(pan_vsp, - "Wrong turn at %s:%d:\n%s\n", file, line, cond); + PAN_linef(pan, "Wrong turn at %s:%d:", file, line); + PAN_linef(pan, " %s", cond); break; case VAS_VCL: - VSB_printf(pan_vsp, - "Panic from VCL:\n %s\n", cond); + PAN_linef(pan, "Panic from VCL:"); + PAN_linef(pan, " %s", cond); break; case VAS_MISSING: - VSB_printf(pan_vsp, - "Missing errorhandling code in %s(), %s line %d:\n" - " Condition(%s) not true.", - func, file, line, cond); + PAN_linef(pan, + "Missing errorhandling code in %s(), %s line %d:", + func, file, line); + PAN_linef(pan, " Condition(%s) not true.", cond); break; case VAS_INCOMPLETE: - VSB_printf(pan_vsp, - "Incomplete code in %s(), %s line %d:\n", + PAN_linef(pan, "Incomplete code in %s(), %s line %d:", func, file, line); break; default: case VAS_ASSERT: - VSB_printf(pan_vsp, - "Assert error in %s(), %s line %d:\n" - " Condition(%s) not true.\n", - func, file, line, cond); + PAN_linef(pan, "Assert error in %s(), %s line %d:", + func, file, line); + PAN_linef(pan, " Condition(%s) not true.", cond); break; } if (err) - VSB_printf(pan_vsp, "errno = %d (%s)\n", err, strerror(err)); + PAN_linef(pan, "errno = %d (%s)", err, strerror(err)); q = THR_GetName(); if (q != NULL) - VSB_printf(pan_vsp, "thread = (%s)\n", q); + PAN_linef(pan, "thread = (%s)", q); - VSB_printf(pan_vsp, "version = %s\n", VCS_version); - VSB_printf(pan_vsp, "ident = %s,%s\n", - VSB_data(vident) + 1, Waiter_GetName()); + PAN_linef(pan, "version = %s", VCS_version); + PAN_linef(pan, "ident = %s,%s", VSB_data(vident) + 1, Waiter_GetName()); pan_backtrace(); @@ -549,8 +550,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond, VSL_Flush(bo->vsl, 0); } } - VSB_printf(pan_vsp, "\n"); - VSB_bcat(pan_vsp, "", 1); /* NUL termination */ + (void)VSB_printf(pan->vsb, "\n"); + (void)VSB_bcat(pan->vsb, "", 1); /* NUL termination */ if (FEATURE(FEATURE_NO_COREDUMP)) exit(4); -- 2.1.4
From ba35eafaa1a9872cf3513d288b90789b29bc849f Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 11:59:31 +0200 Subject: [PATCH 03/16] Change pan_backtrace --- bin/varnishd/cache/cache_panic.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 69bad29..3bd6cb3 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -440,7 +440,7 @@ pan_sess(const struct sess *sp) /*--------------------------------------------------------------------*/ static void -pan_backtrace(void) +pan_backtrace(struct pan *pan) { void *array[10]; size_t size; @@ -448,27 +448,29 @@ pan_backtrace(void) char **strings; char *p; - size = backtrace (array, 10); + size = backtrace(array, 10); if (size == 0) return; - VSB_printf(pan_vsp, "Backtrace:\n"); + PAN_linef(pan, "Backtrace:"); + pan->indent += PAN_IND; for (i = 0; i < size; i++) { - VSB_printf (pan_vsp, " "); - if (Symbol_Lookup(pan_vsp, array[i]) < 0) { + PAN_indent(pan); + if (Symbol_Lookup(pan->vsb, array[i]) < 0) { strings = backtrace_symbols(&array[i], 1); if (strings == NULL || strings[0] == NULL) { - VSB_printf(pan_vsp, "%p: (?)", array[i]); + PAN_printf(pan, "%p: (?)", array[i]); } else { p = strrchr(strings[0], '/'); if (p == NULL) p = strings[0]; else p++; - VSB_printf(pan_vsp, "%p: %s", array[i], p); + PAN_printf(pan, "%p: %s", array[i], p); } } - VSB_printf (pan_vsp, "\n"); + PAN_printf(pan, "\n"); } + pan->indent -= PAN_IND; } /*--------------------------------------------------------------------*/ @@ -536,7 +538,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, PAN_linef(pan, "version = %s", VCS_version); PAN_linef(pan, "ident = %s,%s", VSB_data(vident) + 1, Waiter_GetName()); - pan_backtrace(); + pan_backtrace(pan); if (!FEATURE(FEATURE_SHORT_PANIC)) { req = THR_GetRequest(); -- 2.1.4
From f7d61aa1076e8b78032550a4578af1f1ed5d16a5 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 12:08:42 +0200 Subject: [PATCH 04/16] Change pan_req --- bin/varnishd/cache/cache_panic.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 3bd6cb3..5614cde 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -349,15 +349,15 @@ pan_busyobj(const struct busyobj *bo) /*--------------------------------------------------------------------*/ static void -pan_req(const struct req *req) +pan_req(struct pan *pan, const struct req *req) { const char *stp; - VSB_printf(pan_vsp, "req = %p {\n", req); - - VSB_printf(pan_vsp, " sp = %p, vxid = %u,", - req->sp, VXID(req->vsl->wid)); + PAN_linef(pan, "req = %p {", req); + pan->indent += PAN_IND; + PAN_indent(pan); + PAN_printf(pan, "sp = %p, vxid = %u,", req->sp, VXID(req->vsl->wid)); switch (req->req_step) { #define REQ_STEP(l, u, arg) case R_STP_##u: stp = "R_STP_" #u; break; #include "tbl/steps.h" @@ -365,19 +365,18 @@ pan_req(const struct req *req) default: stp = NULL; } if (stp != NULL) - VSB_printf(pan_vsp, " step = %s,\n", stp); + PAN_printf(pan, " step = %s,\n", stp); else - VSB_printf(pan_vsp, " step = 0x%x,\n", req->req_step); + PAN_printf(pan, " step = 0x%x,\n", req->req_step); - VSB_printf(pan_vsp, " req_body = %s,\n", + PAN_linef(pan, "req_body = %s,", reqbody_status_2str(req->req_body_status)); if (req->err_code) - VSB_printf(pan_vsp, - " err_code = %d, err_reason = %s,\n", req->err_code, + PAN_linef(pan, "err_code = %d, err_reason = %s,", req->err_code, req->err_reason ? req->err_reason : "(null)"); - VSB_printf(pan_vsp, " restarts = %d, esi_level = %d,\n", + PAN_linef(pan, "restarts = %d, esi_level = %d,", req->restarts, req->esi_level); if (req->sp != NULL) @@ -399,13 +398,16 @@ pan_req(const struct req *req) pan_busyobj(req->objcore->busyobj); } - VSB_printf(pan_vsp, " flags = {\n"); -#define REQ_FLAG(l, r, w, d) if(req->l) VSB_printf(pan_vsp, " " #l ",\n"); + PAN_linef(pan, "flags = {"); + pan->indent += PAN_IND; +#define REQ_FLAG(l, r, w, d) if(req->l) PAN_linef(pan, #l ","); #include "tbl/req_flags.h" #undef REQ_FLAG - VSB_printf(pan_vsp, " }\n"); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); - VSB_printf(pan_vsp, "},\n"); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } /*--------------------------------------------------------------------*/ @@ -543,7 +545,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (!FEATURE(FEATURE_SHORT_PANIC)) { req = THR_GetRequest(); if (req != NULL) { - pan_req(req); + pan_req(pan, req); VSL_Flush(req->vsl, 0); } bo = THR_GetBusyobj(); -- 2.1.4
From e8517cdcc33290a6c825101293bc3423fb7eee24 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 12:51:56 +0200 Subject: [PATCH 05/16] Change pan_sess --- bin/varnishd/cache/cache_panic.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 5614cde..671c9aa 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -62,7 +62,7 @@ static struct vsb pan_vsp_storage, *pan_vsp; static pthread_mutex_t panicstr_mtx = PTHREAD_MUTEX_INITIALIZER; -static void pan_sess(const struct sess *sp); +static void pan_sess(struct pan *, const struct sess *sp); /*--------------------------------------------------------------------*/ @@ -380,7 +380,7 @@ pan_req(struct pan *pan, const struct req *req) req->restarts, req->esi_level); if (req->sp != NULL) - pan_sess(req->sp); + pan_sess(pan, req->sp); if (req->wrk != NULL) pan_wrk(req->wrk); @@ -413,18 +413,19 @@ pan_req(struct pan *pan, const struct req *req) /*--------------------------------------------------------------------*/ static void -pan_sess(const struct sess *sp) +pan_sess(struct pan *pan, const struct sess *sp) { const char *stp; char *ci; char *cp; - VSB_printf(pan_vsp, " sp = %p {\n", sp); - VSB_printf(pan_vsp, " fd = %d, vxid = %u,\n", - sp->fd, VXID(sp->vxid)); + PAN_linef(pan, "sp = %p {", sp); + pan->indent += PAN_IND; + + PAN_linef(pan, "fd = %d, vxid = %u,", sp->fd, VXID(sp->vxid)); AZ(SES_Get_client_ip(sp, &ci)); AZ(SES_Get_client_port(sp, &cp)); - VSB_printf(pan_vsp, " client = %s %s,\n", ci, cp); + PAN_linef(pan, "client = %s %s,", ci, cp); switch (sp->sess_step) { #define SESS_STEP(l, u) case S_STP_##u: stp = "S_STP_" #u; break; #include "tbl/steps.h" @@ -432,11 +433,12 @@ pan_sess(const struct sess *sp) default: stp = NULL; } if (stp != NULL) - VSB_printf(pan_vsp, " step = %s,\n", stp); + PAN_linef(pan, "step = %s,", stp); else - VSB_printf(pan_vsp, " step = 0x%x,\n", sp->sess_step); + PAN_linef(pan, "step = 0x%x,", sp->sess_step); - VSB_printf(pan_vsp, " },\n"); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } /*--------------------------------------------------------------------*/ -- 2.1.4
From bcf9090a20abafb61826f6a47b53b74b610c2a7c Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 12:58:54 +0200 Subject: [PATCH 06/16] Change pan_wrk --- bin/varnishd/cache/cache_panic.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 671c9aa..c6e9715 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -255,47 +255,56 @@ pan_objcore(const char *typ, const struct objcore *oc) /*--------------------------------------------------------------------*/ static void -pan_wrk(const struct worker *wrk) +pan_wrk(struct pan *pan, const struct worker *wrk) { const char *hand; unsigned m, u; const char *p; - VSB_printf(pan_vsp, " worker = %p {\n", wrk); - VSB_printf(pan_vsp, " stack = {0x%jx -> 0x%jx}\n", + PAN_linef(pan, "worker = %p {", wrk); + pan->indent += PAN_IND; + + PAN_linef(pan, "stack = {0x%jx -> 0x%jx},", (uintmax_t)wrk->stack_start, (uintmax_t)wrk->stack_end); pan_ws(wrk->aws, 4); m = wrk->cur_method; - VSB_printf(pan_vsp, " VCL::method = "); + PAN_indent(pan); + PAN_printf(pan, "VCL::method = "); if (m == 0) { - VSB_printf(pan_vsp, "none,\n"); + PAN_printf(pan, "none,\n"); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); return; } if (!(m & 1)) - VSB_printf(pan_vsp, "*"); + PAN_printf(pan, "*"); m &= ~1; hand = VCL_Method_Name(m); if (hand != NULL) - VSB_printf(pan_vsp, "%s,\n", hand); + PAN_printf(pan, "%s,\n", hand); else - VSB_printf(pan_vsp, "0x%x,\n", m); + PAN_printf(pan, "0x%x,\n", m); hand = VCL_Return_Name(wrk->handling); if (hand != NULL) - VSB_printf(pan_vsp, " VCL::return = %s,\n", hand); + PAN_linef(pan, "VCL::return = %s,", hand); else - VSB_printf(pan_vsp, " VCL::return = 0x%x,\n", wrk->handling); - VSB_printf(pan_vsp, " VCL::methods = {"); + PAN_linef(pan, "VCL::return = 0x%x,", wrk->handling); + PAN_indent(pan); + PAN_printf(pan, "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)); + PAN_printf(pan, "%s%s", p, VCL_Method_Name(u)); m &= ~u; p = ", "; } } - VSB_printf(pan_vsp, "},\n },\n"); + PAN_printf(pan, "},\n"); + + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } static void @@ -383,7 +392,7 @@ pan_req(struct pan *pan, const struct req *req) pan_sess(pan, req->sp); if (req->wrk != NULL) - pan_wrk(req->wrk); + pan_wrk(pan, req->wrk); pan_ws(req->ws, 2); pan_http("req", req->http, 2); -- 2.1.4
From 33e2ba397ccd9c53192e8be6958b06777d1ad3fd Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:04:53 +0200 Subject: [PATCH 07/16] Change pan_busyobj --- bin/varnishd/cache/cache_panic.c | 41 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index c6e9715..cec77fa 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -308,40 +308,45 @@ pan_wrk(struct pan *pan, const struct worker *wrk) } static void -pan_busyobj(const struct busyobj *bo) +pan_busyobj(struct pan *pan, const struct busyobj *bo) { struct vfp_entry *vfe; - VSB_printf(pan_vsp, " busyobj = %p {\n", bo); + PAN_linef(pan, "busyobj = %p {", bo); + pan->indent += PAN_IND; + pan_ws(bo->ws, 4); - VSB_printf(pan_vsp, " refcnt = %u\n", bo->refcount); - VSB_printf(pan_vsp, " retries = %d\n", bo->retries); - VSB_printf(pan_vsp, " failed = %d\n", bo->vfc->failed); - VSB_printf(pan_vsp, " state = %d\n", (int)bo->state); - VSB_printf(pan_vsp, " flags = {\n"); -#define BO_FLAG(l, r, w, d) if(bo->l) VSB_printf(pan_vsp, " " #l "\n"); + PAN_linef(pan, "refcnt = %u", bo->refcount); + PAN_linef(pan, "retries = %d", bo->retries); + PAN_linef(pan, "failed = %d", bo->vfc->failed); + PAN_linef(pan, "state = %d", (int)bo->state); + PAN_linef(pan, "flags = {"); + pan->indent += PAN_IND; +#define BO_FLAG(l, r, w, d) if(bo->l) PAN_linef(pan, #l ","); #include "tbl/bo_flags.h" #undef BO_FLAG - VSB_printf(pan_vsp, " }\n"); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); if (bo->htc != NULL) { - VSB_printf(pan_vsp, " bodystatus = %d (%s),\n", + PAN_linef(pan, "bodystatus = %d (%s),", bo->htc->body_status, body_status_2str(bo->htc->body_status)); } if (!VTAILQ_EMPTY(&bo->vfc->vfp)) { - VSB_printf(pan_vsp, " filters ="); + PAN_indent(pan); + PAN_printf(pan, "filters ="); VTAILQ_FOREACH(vfe, &bo->vfc->vfp, list) - VSB_printf(pan_vsp, " %s=%d", + PAN_printf(pan, " %s=%d", vfe->vfp->name, (int)vfe->closed); - VSB_printf(pan_vsp, "\n"); + PAN_printf(pan, "\n"); } if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) pan_htc(bo->htc); VDI_Panic(bo->director_req, pan_vsp, "director_req"); if (bo->director_resp == bo->director_req) - VSB_printf(pan_vsp, " director_resp = director_req\n"); + PAN_linef(pan, "director_resp = director_req,"); else VDI_Panic(bo->director_resp, pan_vsp, "director_resp"); if (bo->bereq != NULL && bo->bereq->ws != NULL) @@ -352,7 +357,9 @@ pan_busyobj(const struct busyobj *bo) pan_objcore("FETCH", bo->fetch_objcore); if (bo->stale_oc) pan_objcore("IMS", bo->stale_oc); - VSB_printf(pan_vsp, " }\n"); + + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } /*--------------------------------------------------------------------*/ @@ -404,7 +411,7 @@ pan_req(struct pan *pan, const struct req *req) if (req->objcore != NULL) { pan_objcore("REQ", req->objcore); if (req->objcore->busyobj != NULL) - pan_busyobj(req->objcore->busyobj); + pan_busyobj(pan, req->objcore->busyobj); } PAN_linef(pan, "flags = {"); @@ -561,7 +568,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, } bo = THR_GetBusyobj(); if (bo != NULL) { - pan_busyobj(bo); + pan_busyobj(pan, bo); VSL_Flush(bo->vsl, 0); } } -- 2.1.4
From c43605425572b8b97cb1adbe7dd342acd9771018 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:11:23 +0200 Subject: [PATCH 08/16] Change pan_ws --- bin/varnishd/cache/cache_panic.c | 41 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index cec77fa..e9855c5 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -111,35 +111,38 @@ sess_close_2str(enum sess_close sc, int want_desc) /*--------------------------------------------------------------------*/ static void -pan_ws(const struct ws *ws, int indent) +pan_ws(struct pan *pan, const struct ws *ws) { - VSB_printf(pan_vsp, "%*sws = %p {", indent, "", ws); + PAN_linef(pan, "ws = %p {", ws); + pan->indent += PAN_IND; + if (!VALID_OBJ(ws, WS_MAGIC)) { if (ws != NULL) - VSB_printf(pan_vsp, " BAD_MAGIC(0x%08x) ", ws->magic); + PAN_linef(pan, "BAD_MAGIC(0x%08x),", ws->magic); } else { if (WS_Overflowed(ws)) - VSB_printf(pan_vsp, " OVERFLOW"); - VSB_printf(pan_vsp, - "\n%*sid = \"%s\",\n", indent + 2, "", ws->id); - VSB_printf(pan_vsp, - "%*s{s,f,r,e} = {%p", indent + 2, "", ws->s); + PAN_linef(pan, "OVERFLOW,"); + PAN_linef(pan, "id = \"%s\",", ws->id); + PAN_indent(pan); + PAN_printf(pan, "{s,f,r,e} = {%p", ws->s); if (ws->f > ws->s) - VSB_printf(pan_vsp, ",+%ld", (long) (ws->f - ws->s)); + PAN_printf(pan, ",+%ld", (long)(ws->f - ws->s)); else - VSB_printf(pan_vsp, ",%p", ws->f); + PAN_printf(pan, ",%p", ws->f); if (ws->r > ws->s) - VSB_printf(pan_vsp, ",+%ld", (long) (ws->r - ws->s)); + PAN_printf(pan, ",+%ld", (long)(ws->r - ws->s)); else - VSB_printf(pan_vsp, ",%p", ws->r); + PAN_printf(pan, ",%p", ws->r); if (ws->e > ws->s) - VSB_printf(pan_vsp, ",+%ld", (long) (ws->e - ws->s)); + PAN_printf(pan, ",+%ld", (long)(ws->e - ws->s)); else - VSB_printf(pan_vsp, ",%p", ws->e); + PAN_printf(pan, ",%p", ws->e); } - VSB_printf(pan_vsp, "},\n"); - VSB_printf(pan_vsp, "%*s},\n", indent, "" ); + PAN_printf(pan, "},\n"); + + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } /*--------------------------------------------------------------------*/ @@ -266,7 +269,7 @@ pan_wrk(struct pan *pan, const struct worker *wrk) PAN_linef(pan, "stack = {0x%jx -> 0x%jx},", (uintmax_t)wrk->stack_start, (uintmax_t)wrk->stack_end); - pan_ws(wrk->aws, 4); + pan_ws(pan, wrk->aws); m = wrk->cur_method; PAN_indent(pan); @@ -315,7 +318,7 @@ pan_busyobj(struct pan *pan, const struct busyobj *bo) PAN_linef(pan, "busyobj = %p {", bo); pan->indent += PAN_IND; - pan_ws(bo->ws, 4); + pan_ws(pan, bo->ws); PAN_linef(pan, "refcnt = %u", bo->refcount); PAN_linef(pan, "retries = %d", bo->retries); PAN_linef(pan, "failed = %d", bo->vfc->failed); @@ -401,7 +404,7 @@ pan_req(struct pan *pan, const struct req *req) if (req->wrk != NULL) pan_wrk(pan, req->wrk); - pan_ws(req->ws, 2); + pan_ws(pan, req->ws); pan_http("req", req->http, 2); if (req->resp->ws != NULL) pan_http("resp", req->resp, 2); -- 2.1.4
From 3cd150b821474a95db1ebc0e017c4fee29ee8c7a Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:15:44 +0200 Subject: [PATCH 09/16] Change pan_objcore --- bin/varnishd/cache/cache_panic.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index e9855c5..ed0303b 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -237,22 +237,27 @@ pan_object(const char *typ, const struct object *o) /*--------------------------------------------------------------------*/ static void -pan_objcore(const char *typ, const struct objcore *oc) +pan_objcore(struct pan *pan, const char *typ, const struct objcore *oc) { - VSB_printf(pan_vsp, " objcore (%s) = %p {\n", typ, oc); - VSB_printf(pan_vsp, " refcnt = %d\n", oc->refcnt); - VSB_printf(pan_vsp, " flags = 0x%x\n", oc->flags); - VSB_printf(pan_vsp, " objhead = %p\n", oc->objhead); - VSB_printf(pan_vsp, " stevedore = %p", oc->stobj->stevedore); + PAN_linef(pan, "objcore (%s) = %p {", typ, oc); + pan->indent += PAN_IND; + + PAN_linef(pan, "refcnt = %d", oc->refcnt); + PAN_linef(pan, "flags = 0x%x", oc->flags); + PAN_linef(pan, "objhead = %p", oc->objhead); + PAN_indent(pan); + PAN_printf(pan, "stevedore = %p", oc->stobj->stevedore); if (oc->stobj->stevedore != NULL) { - VSB_printf(pan_vsp, " (%s", oc->stobj->stevedore->name); + PAN_printf(pan, " (%s", oc->stobj->stevedore->name); if (strlen(oc->stobj->stevedore->ident)) - VSB_printf(pan_vsp, " %s", oc->stobj->stevedore->ident); - VSB_printf(pan_vsp, ")"); + PAN_printf(pan, " %s", oc->stobj->stevedore->ident); + PAN_printf(pan, ")"); } - VSB_printf(pan_vsp, "\n"); - VSB_printf(pan_vsp, " }\n"); + PAN_printf(pan, "\n"); + + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } /*--------------------------------------------------------------------*/ @@ -357,9 +362,9 @@ pan_busyobj(struct pan *pan, const struct busyobj *bo) if (bo->beresp != NULL && bo->beresp->ws != NULL) pan_http("beresp", bo->beresp, 4); if (bo->fetch_objcore) - pan_objcore("FETCH", bo->fetch_objcore); + pan_objcore(pan, "FETCH", bo->fetch_objcore); if (bo->stale_oc) - pan_objcore("IMS", bo->stale_oc); + pan_objcore(pan, "IMS", bo->stale_oc); pan->indent -= PAN_IND; PAN_linef(pan, "},"); @@ -412,7 +417,7 @@ pan_req(struct pan *pan, const struct req *req) VCL_Panic(pan_vsp, req->vcl); if (req->objcore != NULL) { - pan_objcore("REQ", req->objcore); + pan_objcore(pan, "REQ", req->objcore); if (req->objcore->busyobj != NULL) pan_busyobj(pan, req->objcore->busyobj); } -- 2.1.4
From e25785b8113ad88625886569ee4e18f2683b9076 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:33:48 +0200 Subject: [PATCH 10/16] Change pan_http --- bin/varnishd/cache/cache_panic.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index ed0303b..6dd0aae 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -196,21 +196,22 @@ pan_storage(const struct storage *st) /*--------------------------------------------------------------------*/ static void -pan_http(const char *id, const struct http *h, int indent) +pan_http(struct pan *pan, const char *id, const struct http *h) { int i; - VSB_printf(pan_vsp, "%*shttp[%s] = {\n", indent, "", id); - VSB_printf(pan_vsp, "%*sws = %p[%s]\n", indent + 2, "", - h->ws, h->ws ? h->ws->id : ""); + PAN_linef(pan, "http[%s] = {", id); + pan->indent += PAN_IND; + PAN_linef(pan, "ws = %p[%s],", h->ws, h->ws ? h->ws->id : ""); for (i = 0; i < h->nhd; ++i) { if (h->hd[i].b == NULL && h->hd[i].e == NULL) continue; - VSB_printf(pan_vsp, "%*s\"%.*s\",\n", indent + 4, "", + PAN_linef(pan, "\"%.*s\",", (int)(h->hd[i].e - h->hd[i].b), h->hd[i].b); } - VSB_printf(pan_vsp, "%*s},\n", indent, ""); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } @@ -358,9 +359,9 @@ pan_busyobj(struct pan *pan, const struct busyobj *bo) else VDI_Panic(bo->director_resp, pan_vsp, "director_resp"); if (bo->bereq != NULL && bo->bereq->ws != NULL) - pan_http("bereq", bo->bereq, 4); + pan_http(pan, "bereq", bo->bereq); if (bo->beresp != NULL && bo->beresp->ws != NULL) - pan_http("beresp", bo->beresp, 4); + pan_http(pan, "beresp", bo->beresp); if (bo->fetch_objcore) pan_objcore(pan, "FETCH", bo->fetch_objcore); if (bo->stale_oc) @@ -410,9 +411,9 @@ pan_req(struct pan *pan, const struct req *req) pan_wrk(pan, req->wrk); pan_ws(pan, req->ws); - pan_http("req", req->http, 2); + pan_http(pan, "req", req->http); if (req->resp->ws != NULL) - pan_http("resp", req->resp, 2); + pan_http(pan, "resp", req->resp); VCL_Panic(pan_vsp, req->vcl); -- 2.1.4
From 0a4fee7f6f3abe53ccd5f29ff0ec4535efd8554c Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:51:35 +0200 Subject: [PATCH 11/16] Change pan_htc --- bin/varnishd/cache/cache_panic.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 6dd0aae..2c6a7c9 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -148,12 +148,14 @@ pan_ws(struct pan *pan, const struct ws *ws) /*--------------------------------------------------------------------*/ static void -pan_htc(const struct http_conn *htc) +pan_htc(struct pan *pan, const struct http_conn *htc) { - VSB_printf(pan_vsp, " http_conn = %p {\n", htc); - VSB_printf(pan_vsp, " fd = %d,\n", htc->fd); - VSB_printf(pan_vsp, " },\n"); + PAN_linef(pan, "http_conn = %p {", htc); + pan->indent += PAN_IND; + PAN_linef(pan, "fd = %d,", htc->fd); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } /*--------------------------------------------------------------------*/ @@ -352,7 +354,7 @@ pan_busyobj(struct pan *pan, const struct busyobj *bo) } if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) - pan_htc(bo->htc); + pan_htc(pan, bo->htc); VDI_Panic(bo->director_req, pan_vsp, "director_req"); if (bo->director_resp == bo->director_req) PAN_linef(pan, "director_resp = director_req,"); -- 2.1.4
From 6c75a47426b4a543abb2cdd6da6dc2664afab602 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:43:30 +0200 Subject: [PATCH 12/16] Change VDI_Panic --- bin/varnishd/cache/cache_backend.c | 26 ++++++++++++++------------ bin/varnishd/cache/cache_director.c | 15 +++++++++------ bin/varnishd/cache/cache_director.h | 5 +++-- bin/varnishd/cache/cache_panic.c | 4 ++-- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 7ed2673..e7baa13 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -39,6 +39,7 @@ #include "vrt.h" #include "vtcp.h" #include "vtim.h" +#include "pan.h" #include "cache_director.h" #include "cache_backend.h" @@ -332,31 +333,32 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) /*--------------------------------------------------------------------*/ static void -vbe_panic(const struct director *d, struct vsb *vsb) +vbe_panic(struct pan *pan, const struct director *d) { struct backend *bp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); - VSB_printf(vsb, " display_name = %s\n", bp->display_name); + PAN_linef(pan, "display_name = %s,", bp->display_name); if (bp->ipv4_addr != NULL) - VSB_printf(vsb, " ipv4 = %s\n", bp->ipv4_addr); + PAN_linef(pan, "ipv4 = %s,", bp->ipv4_addr); if (bp->ipv6_addr != NULL) - VSB_printf(vsb, " ipv6 = %s\n", bp->ipv6_addr); - VSB_printf(vsb, " port = %s\n", bp->port); - VSB_printf(vsb, " hosthdr = %s\n", bp->hosthdr); - VSB_printf(vsb, " health=%s, admin_health=", + PAN_linef(pan, "ipv6 = %s,", bp->ipv6_addr); + PAN_linef(pan, "port = %s,", bp->port); + PAN_linef(pan, "hosthdr = %s,", bp->hosthdr); + PAN_indent(pan); + PAN_printf(pan, "health=%s, admin_health=", bp->healthy ? "healthy" : "sick"); if (bp->admin_health == ah_probe) - VSB_printf(vsb, "probe"); + PAN_printf(pan, "probe"); else if (bp->admin_health == ah_sick) - VSB_printf(vsb, "sick"); + PAN_printf(pan, "sick"); else if (bp->admin_health == ah_healthy) - VSB_printf(vsb, "healthy"); + PAN_printf(pan, "healthy"); else - VSB_printf(vsb, "*invalid*"); - VSB_printf(vsb, ", changed=%.1f\n", bp->health_changed); + PAN_printf(pan, "*invalid*"); + PAN_printf(pan, ", changed=%.1f\n", bp->health_changed); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index f7e0479..15cc66d 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -36,6 +36,7 @@ #include "config.h" #include "cache.h" +#include "pan.h" #include "cache_director.h" @@ -183,14 +184,16 @@ VDI_Healthy(const struct director *d, const struct busyobj *bo) */ void -VDI_Panic(const struct director *d, struct vsb *vsb, const char *nm) +VDI_Panic(struct pan *pan, const struct director *d, const char *nm) { if (d == NULL) return; - VSB_printf(vsb, " %s = %p {\n", nm, d); - VSB_printf(vsb, " vcl_name = %s\n", d->vcl_name); - VSB_printf(vsb, " name = %s\n", d->name); + PAN_linef(pan, "%s = %p {", nm, d); + pan->indent += PAN_IND; + PAN_linef(pan, "vcl_name = %s", d->vcl_name); + PAN_linef(pan, "name = %s", d->name); if (d->panic != NULL) - d->panic(d, vsb); - VSB_printf(vsb, " }\n"); + d->panic(pan, d); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index cf20dc1..3a087ef 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -42,6 +42,7 @@ * backends to use. */ +struct pan; typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, double *changed); @@ -61,7 +62,7 @@ typedef void vdi_finish_f(const struct director *, struct worker *, typedef void vdi_http1pipe_f(const struct director *, struct req *, struct busyobj *); -typedef void vdi_panic_f(const struct director *, struct vsb *); +typedef void vdi_panic_f(struct pan *, const struct director *); struct director { unsigned magic; @@ -91,4 +92,4 @@ void VDI_Finish(struct worker *wrk, struct busyobj *bo); int VDI_Http1Pipe(struct req *, struct busyobj *); int VDI_Healthy(const struct director *, const struct busyobj *); -void VDI_Panic(const struct director *, struct vsb *, const char *nm); +void VDI_Panic(struct pan *, const struct director *, const char *nm); diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 2c6a7c9..c49da37 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -355,11 +355,11 @@ pan_busyobj(struct pan *pan, const struct busyobj *bo) if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) pan_htc(pan, bo->htc); - VDI_Panic(bo->director_req, pan_vsp, "director_req"); + VDI_Panic(pan, bo->director_req, "director_req"); if (bo->director_resp == bo->director_req) PAN_linef(pan, "director_resp = director_req,"); else - VDI_Panic(bo->director_resp, pan_vsp, "director_resp"); + VDI_Panic(pan, bo->director_resp, "director_resp"); if (bo->bereq != NULL && bo->bereq->ws != NULL) pan_http(pan, "bereq", bo->bereq); if (bo->beresp != NULL && bo->beresp->ws != NULL) -- 2.1.4
From 225efb12357038790720ba92c8f4fdd4cfdcae1a Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:49:14 +0200 Subject: [PATCH 13/16] Change VCL_Panic --- bin/varnishd/cache/cache.h | 3 ++- bin/varnishd/cache/cache_panic.c | 2 +- bin/varnishd/cache/cache_vcl.c | 22 ++++++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b96d765..6e025d3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -123,6 +123,7 @@ struct vsb; struct waitinglist; struct worker; struct v1l; +struct pan; #define DIGEST_LEN 32 @@ -1046,7 +1047,7 @@ const struct vrt_backend_probe *VCL_DefaultProbe(const struct vcl *); void VCL_Init(void); const char *VCL_Method_Name(unsigned); const char *VCL_Name(const struct vcl *); -void VCL_Panic(struct vsb *, const struct vcl *); +void VCL_Panic(struct pan *, const struct vcl *); void VCL_Poll(void); void VCL_Ref(struct vcl *); void VCL_Refresh(struct vcl **); diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index c49da37..162d5af 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -417,7 +417,7 @@ pan_req(struct pan *pan, const struct req *req) if (req->resp->ws != NULL) pan_http(pan, "resp", req->resp); - VCL_Panic(pan_vsp, req->vcl); + VCL_Panic(pan, req->vcl); if (req->objcore != NULL) { pan_objcore(pan, "REQ", req->objcore); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 6df2a2f..838835f 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -41,6 +41,7 @@ #include "vcl.h" #include "vrt.h" +#include "pan.h" #include "cache_director.h" #include "cache_backend.h" @@ -78,19 +79,24 @@ static struct vcl *vcl_active; /* protected by vcl_mtx */ /*--------------------------------------------------------------------*/ void -VCL_Panic(struct vsb *vsb, const struct vcl *vcl) +VCL_Panic(struct pan *pan, const struct vcl *vcl) { int i; - AN(vsb); - if (vcl == NULL) + if (vcl == NULL) { + PAN_linef(pan, "vcl = NULL,"); return; - VSB_printf(vsb, " vcl = {\n"); - VSB_printf(vsb, " srcname = {\n"); + } + PAN_linef(pan, "vcl = %p {", vcl); + pan->indent += PAN_IND; + PAN_linef(pan, "srcname = {"); + pan->indent += PAN_IND; for (i = 0; i < vcl->conf->nsrc; ++i) - VSB_printf(vsb, " \"%s\",\n", vcl->conf->srcname[i]); - VSB_printf(vsb, " },\n"); - VSB_printf(vsb, " },\n"); + PAN_linef(pan, "\"%s\",", vcl->conf->srcname[i]); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } /*--------------------------------------------------------------------*/ -- 2.1.4
From 38834b291664c833ca8aab17d799e879aee4ec41 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Wed, 1 Jul 2015 17:36:42 +0200 Subject: [PATCH 14/16] Call VCL_Panic also from pan_busyobj --- bin/varnishd/cache/cache_panic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 162d5af..0b371c2 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -368,6 +368,7 @@ pan_busyobj(struct pan *pan, const struct busyobj *bo) pan_objcore(pan, "FETCH", bo->fetch_objcore); if (bo->stale_oc) pan_objcore(pan, "IMS", bo->stale_oc); + VCL_Panic(pan, bo->vcl); pan->indent -= PAN_IND; PAN_linef(pan, "},"); -- 2.1.4
From 67b94b4467c8673ea0e712ba8353d712374f1ab2 Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:52:23 +0200 Subject: [PATCH 15/16] Drop pan_vsp now that it's unused --- bin/varnishd/cache/cache_panic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 0b371c2..8ac9d16 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -59,7 +59,7 @@ * (gdb) printf "%s", panicstr */ -static struct vsb pan_vsp_storage, *pan_vsp; +static struct vsb pan_vsp_storage; static pthread_mutex_t panicstr_mtx = PTHREAD_MUTEX_INITIALIZER; static void pan_sess(struct pan *, const struct sess *sp); @@ -660,10 +660,9 @@ PAN_Init(void) { VAS_Fail = pan_ic; - pan_vsp = &pan_vsp_storage; AN(heritage.panic_str); AN(heritage.panic_str_len); - AN(VSB_new(pan_vsp, heritage.panic_str, heritage.panic_str_len, + AN(VSB_new(&pan_vsp_storage, heritage.panic_str, heritage.panic_str_len, VSB_FIXEDLEN)); CLI_AddFuncs(debug_cmds); } -- 2.1.4
From cd3fa1ed5feb6097a4f1003665e1d4fd40ad022e Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland <[email protected]> Date: Thu, 2 Jul 2015 13:58:28 +0200 Subject: [PATCH 16/16] Change a couple of unused panic generators to the new format --- bin/varnishd/cache/cache_panic.c | 46 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 8ac9d16..b3eab8c 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -162,33 +162,33 @@ pan_htc(struct pan *pan, const struct http_conn *htc) #if 0 static void -pan_storage(const struct storage *st) +pan_storage(struct pan *pan, const struct storage *st) { int i, j; #define MAX_BYTES (4*16) #define show(ch) (((ch) > 31 && (ch) < 127) ? (ch) : '.') - VSB_printf(pan_vsp, " %u {\n", st->len); + PAN_linef(pan, "%u {", st->len); + pan->indent += PAN_IND; for (i = 0; i < MAX_BYTES && i < st->len; i += 16) { - VSB_printf(pan_vsp, " "); + PAN_indent(pan); for (j = 0; j < 16; ++j) { if (i + j < st->len) - VSB_printf(pan_vsp, "%02x ", st->ptr[i + j]); + PAN_printf(pan, "%02x ", st->ptr[i + j]); else - VSB_printf(pan_vsp, " "); + PAN_printf(pan, " "); } - VSB_printf(pan_vsp, "|"); + PAN_printf(pan, "|"); for (j = 0; j < 16; ++j) if (i + j < st->len) - VSB_printf(pan_vsp, - "%c", show(st->ptr[i + j])); - VSB_printf(pan_vsp, "|\n"); + PAN_printf(pan, "%c", show(st->ptr[i + j])); + PAN_printf(pan, "|\n"); } if (st->len > MAX_BYTES) - VSB_printf(pan_vsp, - " [%u more]\n", st->len - MAX_BYTES); - VSB_printf(pan_vsp, " },\n"); + PAN_linef(pan, "[%u more]", st->len - MAX_BYTES); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); #undef show #undef MAX_BYTES @@ -221,19 +221,23 @@ pan_http(struct pan *pan, const char *id, const struct http *h) #if 0 static void -pan_object(const char *typ, const struct object *o) +pan_object(struct pan *, const char *typ, const struct object *o) { const struct storage *st; - VSB_printf(pan_vsp, " obj (%s) = %p {\n", typ, o); - VSB_printf(pan_vsp, " vxid = %u,\n", VXID(vbe32dec(o->oa_vxid))); - pan_http("obj", o->http, 4); - VSB_printf(pan_vsp, " len = %jd,\n", (intmax_t)o->body->len); - VSB_printf(pan_vsp, " store = {\n"); + PAN_linef(pan, "obj (%s) = %p {", typ, o); + pan->indent += PAN_IND; + PAN_linef(pan, "vxid = %u,", VXID(vbe32dec(o->oa_vxid))); + pan_http(pan, "obj", o->http); + PAN_linef(pan, "len = %jd,", (intmax_t)o->body->len); + PAN_linef(pan, "store = {"); + pan->indent += PAN_IND; VTAILQ_FOREACH(st, &o->body->list, list) - pan_storage(st); - VSB_printf(pan_vsp, " },\n"); - VSB_printf(pan_vsp, " },\n"); + pan_storage(pan, st); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); + pan->indent -= PAN_IND; + PAN_linef(pan, "},"); } #endif -- 2.1.4
_______________________________________________ varnish-dev mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
