]> err.no Git - varnish/commitdiff
Add diag_bitmap controls for panic behaviour.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 20 Jul 2008 11:40:30 +0000 (11:40 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 20 Jul 2008 11:40:30 +0000 (11:40 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2977 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_panic.c
varnish-cache/bin/varnishd/mgt_param.c

index 4bd54dc661e17b6fbca42b9098af69aa4c8ddd50..00cb9078ee302011b823582ccf7dc13b350650d5 100644 (file)
@@ -35,6 +35,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "cache.h"
 #include "cache_backend.h"
 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();
 }
 
 /*--------------------------------------------------------------------*/
index f2f8893fa8744019e4324f519ac6188a8bbee0c0..db51fac3f44d9797674f7959c512b7641f4878df 100644 (file)
@@ -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" },