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 @@ ...@@ -34,6 +34,7 @@
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "cache.h" #include "cache.h"
...@@ -48,14 +49,19 @@ ...@@ -48,14 +49,19 @@
char panicstr[65536]; char panicstr[65536];
static char *pstr = panicstr; static char *pstr = panicstr;
#define fp(...) \ #define fp(...) \
pstr += snprintf(pstr, \ do { \
(panicstr + sizeof panicstr) - pstr, \ pstr += snprintf(pstr, \
__VA_ARGS__) (panicstr + sizeof panicstr) - pstr, \
#define vfp(fmt, ap) \ __VA_ARGS__); \
pstr += vsnprintf(pstr, \ } while (0)
(panicstr + sizeof panicstr) - pstr, \
(fmt), (ap)) #define vfp(fmt, ap) \
do { \
pstr += vsnprintf(pstr, \
(panicstr + sizeof panicstr) - pstr, \
(fmt), (ap)); \
} while (0)
/* step names */ /* step names */
static const char *steps[] = { static const char *steps[] = {
...@@ -195,11 +201,23 @@ panic(const char *file, int line, const char *func, ...@@ -195,11 +201,23 @@ panic(const char *file, int line, const char *func,
if (VALID_OBJ(sp, SESS_MAGIC)) if (VALID_OBJ(sp, SESS_MAGIC))
dump_sess(sp); dump_sess(sp);
fputs(panicstr, stderr); (void)fputs(panicstr, stderr);
/* I wish there was a way to flush the log buffers... */ /* I wish there was a way to flush the log buffers... */
signal(SIGABRT, SIG_DFL); (void)signal(SIGABRT, SIG_DFL);
raise(SIGABRT); #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 #endif
...@@ -100,6 +100,7 @@ AC_CHECK_FUNCS([socket]) ...@@ -100,6 +100,7 @@ AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([strptime]) AC_CHECK_FUNCS([strptime])
AC_CHECK_FUNCS([fmtcheck]) AC_CHECK_FUNCS([fmtcheck])
AC_CHECK_FUNCS([getdtablesize]) AC_CHECK_FUNCS([getdtablesize])
AC_CHECK_FUNCS([abort2])
save_LIBS="${LIBS}" save_LIBS="${LIBS}"
LIBS="${PTHREAD_LIBS}" LIBS="${PTHREAD_LIBS}"
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
*/ */
struct cli { struct cli {
/* XXX: should be MINI_OBJ */
struct vsb *sb; struct vsb *sb;
enum cli_status_e result; 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