Commit 840ab584 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Simplify the panic string processing



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4800 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 02b4cec6
...@@ -44,6 +44,7 @@ SVNID("$Id$") ...@@ -44,6 +44,7 @@ SVNID("$Id$")
#include <execinfo.h> #include <execinfo.h>
#endif #endif
#include "cache.h" #include "cache.h"
#include "shmlog.h"
#include "cache_backend.h" #include "cache_backend.h"
#include "vcl.h" #include "vcl.h"
#include "libvcl.h" #include "libvcl.h"
...@@ -57,7 +58,6 @@ SVNID("$Id$") ...@@ -57,7 +58,6 @@ SVNID("$Id$")
* (gdb) printf "%s", panicstr * (gdb) printf "%s", panicstr
*/ */
char panicstr[65536];
static struct vsb vsps, *vsp; static struct vsb vsps, *vsp;
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
...@@ -294,7 +294,6 @@ static void ...@@ -294,7 +294,6 @@ static void
pan_ic(const char *func, const char *file, int line, const char *cond, pan_ic(const char *func, const char *file, int line, const char *cond,
int err, int xxx) int err, int xxx)
{ {
int l;
char *p; char *p;
const char *q; const char *q;
const struct sess *sp; const struct sess *sp;
...@@ -341,22 +340,19 @@ pan_ic(const char *func, const char *file, int line, const char *cond, ...@@ -341,22 +340,19 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
} }
vsb_printf(vsp, "\n"); vsb_printf(vsp, "\n");
vsb_bcat(vsp, "", 1); /* NUL termination */ vsb_bcat(vsp, "", 1); /* NUL termination */
VSL_Panic(&l, &p);
if (l < sizeof(panicstr))
l = sizeof(panicstr);
memcpy(p, panicstr, l);
if (params->diag_bitmap & 0x4000) if (params->diag_bitmap & 0x4000)
(void)fputs(panicstr, stderr); (void)fputs(loghead->panicstr, stderr);
#ifdef HAVE_ABORT2 #ifdef HAVE_ABORT2
if (params->diag_bitmap & 0x8000) { if (params->diag_bitmap & 0x8000) {
void *arg[1]; void *arg[1];
for (p = panicstr; *p; p++) for (p = loghead->panicstr; *p; p++)
if (*p == '\n') if (*p == '\n')
*p = ' '; *p = ' ';
arg[0] = panicstr; arg[0] = loghead->panicstr;
abort2(panicstr, 1, arg); abort2(loghead->panicstr, 1, arg);
} }
#endif #endif
if (params->diag_bitmap & 0x1000) if (params->diag_bitmap & 0x1000)
...@@ -373,5 +369,6 @@ PAN_Init(void) ...@@ -373,5 +369,6 @@ PAN_Init(void)
lbv_assert = pan_ic; lbv_assert = pan_ic;
vsp = &vsps; vsp = &vsps;
AN(vsb_new(vsp, panicstr, sizeof panicstr, VSB_FIXEDLEN)); AN(vsb_new(vsp, loghead->panicstr, sizeof loghead->panicstr,
VSB_FIXEDLEN));
} }
...@@ -265,25 +265,6 @@ WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...) ...@@ -265,25 +265,6 @@ WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void
VSL_Panic(int *len, char **ptr)
{
static char a[1] = { '\0' };
AN(len);
AN(ptr);
if (loghead->magic == SHMLOGHEAD_MAGIC) {
assert(loghead->hdrsize == sizeof *loghead);
*len = sizeof(loghead->panicstr);
*ptr = loghead->panicstr;
} else {
*len = 0;
*ptr = a;
}
}
/*--------------------------------------------------------------------*/
void void
VSL_Init(void) VSL_Init(void)
{ {
......
...@@ -38,9 +38,6 @@ extern pid_t mgt_pid; ...@@ -38,9 +38,6 @@ extern pid_t mgt_pid;
/* cache_acceptor.c */ /* cache_acceptor.c */
void VCA_tweak_waiter(struct cli *cli, const char *arg); void VCA_tweak_waiter(struct cli *cli, const char *arg);
/* shmlog.c */
void VSL_Panic(int *len, char **ptr);
/* mgt_shmem.c */ /* mgt_shmem.c */
extern struct varnish_stats *VSL_stats; extern struct varnish_stats *VSL_stats;
extern struct shmloghead *loghead; extern struct shmloghead *loghead;
......
...@@ -59,6 +59,7 @@ SVNID("$Id$") ...@@ -59,6 +59,7 @@ SVNID("$Id$")
#endif #endif
#include "mgt.h" #include "mgt.h"
#include "shmlog.h"
#include "heritage.h" #include "heritage.h"
#include "cli.h" #include "cli.h"
#include "cli_priv.h" #include "cli_priv.h"
...@@ -459,13 +460,11 @@ mgt_stop_child(void) ...@@ -459,13 +460,11 @@ mgt_stop_child(void)
static void static void
mgt_report_panic(pid_t r) mgt_report_panic(pid_t r)
{ {
int l;
char *p;
VSL_Panic(&l, &p); if (loghead->panicstr[0] == '\0')
if (*p == '\0')
return; return;
REPORT(LOG_ERR, "Child (%jd) Panic message: %s", (intmax_t)r, p); REPORT(LOG_ERR, "Child (%jd) Panic message: %s",
(intmax_t)r, loghead->panicstr);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
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