Commit bfa94ee9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Use the abort2(2) function to record our panic string, if we have it.

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



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2478 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 75908c17
......@@ -34,6 +34,7 @@
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "cache.h"
......@@ -48,14 +49,19 @@
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[] = {
......@@ -195,11 +201,23 @@ panic(const char *file, int line, const char *func,
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
......@@ -100,6 +100,7 @@ AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([strptime])
AC_CHECK_FUNCS([fmtcheck])
AC_CHECK_FUNCS([getdtablesize])
AC_CHECK_FUNCS([abort2])
save_LIBS="${LIBS}"
LIBS="${PTHREAD_LIBS}"
......
......@@ -30,6 +30,7 @@
*/
struct cli {
/* XXX: should be MINI_OBJ */
struct vsb *sb;
enum cli_status_e result;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment