]> err.no Git - varnish/commitdiff
Use the abort2(2) function to record our panic string, if we have it.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Feb 2008 12:30:47 +0000 (12:30 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Feb 2008 12:30:47 +0000 (12:30 +0000)
Protect macros with do {....} while(0)

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2478 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_panic.c
varnish-cache/configure.ac
varnish-cache/include/cli_common.h

index f2c6d97ce804d132bfdd9bbde86e059cc4faa5f3..22dc6c8eeb602e7a331ad6854e1deae457e622f1 100644 (file)
@@ -34,6 +34,7 @@
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "cache.h"
 
 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
index ec36bda7af1af23833c71e6cd127866a423a9aa3..f3f0457cff7058ee3df4faaa2aa0ea92193d59a6 100644 (file)
@@ -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}"
index 04fff6f8712a3829e6237096a2e4adcd8f66fe97..53bec5e98d6a0fc72f605190cb6a8907b5eeb6df 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 struct cli {
+       /* XXX: should be MINI_OBJ */
        struct vsb              *sb;
        enum cli_status_e       result;
 };