r2478 - in trunk/varnish-cache: . bin/varnishd include

phk at projects.linpro.no phk at projects.linpro.no
Fri Feb 15 13:30:47 CET 2008


Author: phk
Date: 2008-02-15 13:30:47 +0100 (Fri, 15 Feb 2008)
New Revision: 2478

Modified:
   trunk/varnish-cache/bin/varnishd/cache_panic.c
   trunk/varnish-cache/configure.ac
   trunk/varnish-cache/include/cli_common.h
Log:
Use the abort2(2) function to record our panic string, if we have it.

Protect macros with do {....} while(0)



Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_panic.c	2008-02-15 11:52:41 UTC (rev 2477)
+++ trunk/varnish-cache/bin/varnishd/cache_panic.c	2008-02-15 12:30:47 UTC (rev 2478)
@@ -34,6 +34,7 @@
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "cache.h"
 
@@ -48,15 +49,20 @@
 char panicstr[65536];
 static char *pstr = panicstr;
 
-#define fp(...)						\
-	pstr += snprintf(pstr,				\
-	    (panicstr + sizeof panicstr) - pstr,	\
-	    __VA_ARGS__)
-#define vfp(fmt, ap)					\
-	pstr += vsnprintf(pstr,				\
-	    (panicstr + sizeof panicstr) - pstr,	\
-	    (fmt), (ap))
+#define fp(...)							\
+	do {							\
+		pstr += snprintf(pstr,				\
+		    (panicstr + sizeof panicstr) - pstr,	\
+		    __VA_ARGS__);				\
+	} while (0)
 
+#define vfp(fmt, ap)						\
+	do {							\
+		pstr += vsnprintf(pstr,				\
+		    (panicstr + sizeof panicstr) - pstr,	\
+		    (fmt), (ap));				\
+	} while (0)
+
 /* step names */
 static const char *steps[] = {
 #define STEP(l, u) "STP_" #u,
@@ -195,11 +201,23 @@
 	if (VALID_OBJ(sp, SESS_MAGIC))
 		dump_sess(sp);
 
-	fputs(panicstr, stderr);
+	(void)fputs(panicstr, stderr);
 
 	/* I wish there was a way to flush the log buffers... */
-	signal(SIGABRT, SIG_DFL);
-	raise(SIGABRT);
+	(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

Modified: trunk/varnish-cache/configure.ac
===================================================================
--- trunk/varnish-cache/configure.ac	2008-02-15 11:52:41 UTC (rev 2477)
+++ trunk/varnish-cache/configure.ac	2008-02-15 12:30:47 UTC (rev 2478)
@@ -100,6 +100,7 @@
 AC_CHECK_FUNCS([strptime])
 AC_CHECK_FUNCS([fmtcheck])
 AC_CHECK_FUNCS([getdtablesize])
+AC_CHECK_FUNCS([abort2])
 
 save_LIBS="${LIBS}"
 LIBS="${PTHREAD_LIBS}"

Modified: trunk/varnish-cache/include/cli_common.h
===================================================================
--- trunk/varnish-cache/include/cli_common.h	2008-02-15 11:52:41 UTC (rev 2477)
+++ trunk/varnish-cache/include/cli_common.h	2008-02-15 12:30:47 UTC (rev 2478)
@@ -30,6 +30,7 @@
  */
 
 struct cli {
+	/* XXX: should be MINI_OBJ */
 	struct vsb		*sb;
 	enum cli_status_e	result;
 };




More information about the varnish-commit mailing list