From: phk Date: Sun, 20 Jul 2008 11:40:30 +0000 (+0000) Subject: Add diag_bitmap controls for panic behaviour. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4c87948c1787799896e7456864cdc3b82e9e5af;p=varnish Add diag_bitmap controls for panic behaviour. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2977 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_panic.c b/varnish-cache/bin/varnishd/cache_panic.c index 4bd54dc6..00cb9078 100644 --- a/varnish-cache/bin/varnishd/cache_panic.c +++ b/varnish-cache/bin/varnishd/cache_panic.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "cache.h" #include "cache_backend.h" @@ -52,43 +53,6 @@ char panicstr[65536]; static struct vsb vsps, *vsp; -#if 0 - -void -panic(const char *file, int line, const char *func, - const struct sess *sp, const char *fmt, ...) -{ - va_list ap; - - vsb_printf(vsp, "panic in %s() at %s:%d\n", func, file, line); - va_start(ap, fmt); - vvsb_printf(vsp, fmt, ap); - va_end(ap); - - if (VALID_OBJ(sp, SESS_MAGIC)) - dump_sess(sp); - - (void)fputs(panicstr, stderr); - - /* I wish there was a way to flush the log buffers... */ - (void)signal(SIGABRT, SIG_DFL); -#ifdef HAVE_ABORT2 - { - void *arg[1]; - char *p; - - for (p = panicstr; *p; p++) - if (*p == '\n') - *p = ' '; - arg[0] = panicstr; - abort2(panicstr, 1, arg); - } -#endif - (void)raise(SIGABRT); -} - -#endif - /*--------------------------------------------------------------------*/ static void @@ -255,15 +219,35 @@ pan_ic(const char *func, const char *file, int line, const char *cond, int err, q = THR_GetName(); if (q != NULL) vsb_printf(vsp, " thread = (%s)", q); - sp = THR_GetSession(); - if (sp != NULL) - pan_sess(sp); + if (!(params->diag_bitmap & 0x2000)) { + sp = THR_GetSession(); + if (sp != NULL) + pan_sess(sp); + } vsb_printf(vsp, "\n"); + vsb_bcat(vsp, "", 1); /* NUL termination */ VSL_Panic(&l, &p); if (l < sizeof(panicstr)) l = sizeof(panicstr); memcpy(p, panicstr, l); - abort(); + if (params->diag_bitmap & 0x4000) + fputs(panicstr, stderr); + +#ifdef HAVE_ABORT2 + if (params->diag_bitmap & 0x8000) { + void *arg[1]; + + for (p = panicstr; *p; p++) + if (*p == '\n') + *p = ' '; + arg[0] = panicstr; + abort2(panicstr, 1, arg); + } +#endif + if (params->diag_bitmap & 0x1000) + kill(getpid(), SIGUSR1); + else + abort(); } /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index f2f8893f..db51fac3 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -786,6 +786,12 @@ static const struct parspec parspec[] = { " 0x00000010 - mutex contests.\n" " 0x00000020 - waiting list.\n" " 0x00000040 - object workspace.\n" + " 0x00001000 - do not core-dump child process.\n" + " 0x00002000 - only short panic message.\n" + " 0x00004000 - panic to stderr.\n" +#ifdef HAVE_ABORT2 + " 0x00008000 - panic to abort2().\n" +#endif "Use 0x notation and do the bitor in your head :-)\n", 0, "0", "bitmap" },