r2977 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sun Jul 20 13:40:30 CEST 2008


Author: phk
Date: 2008-07-20 13:40:30 +0200 (Sun, 20 Jul 2008)
New Revision: 2977

Modified:
   trunk/varnish-cache/bin/varnishd/cache_panic.c
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Add diag_bitmap controls for panic behaviour.



Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_panic.c	2008-07-20 11:28:40 UTC (rev 2976)
+++ trunk/varnish-cache/bin/varnishd/cache_panic.c	2008-07-20 11:40:30 UTC (rev 2977)
@@ -35,6 +35,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #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 @@
 	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();
 }
 
 /*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-07-20 11:28:40 UTC (rev 2976)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-07-20 11:40:30 UTC (rev 2977)
@@ -786,6 +786,12 @@
 		"  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" },




More information about the varnish-commit mailing list