[master] ceaf73d Make the panicstr a VSM allocation
Poul-Henning Kamp
phk at varnish-cache.org
Wed Nov 16 07:43:23 CET 2011
commit ceaf73d70ae92b81440615709789cf6101f18a51
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Nov 16 06:22:49 2011 +0000
Make the panicstr a VSM allocation
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index c626ae3..d112eb8 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -40,8 +40,6 @@
#include "cache.h"
-#include "vapi/vsm_int.h"
-
#include "cache_backend.h"
#include "waiter/cache_waiter.h"
#include "vcl.h"
@@ -58,6 +56,10 @@
static struct vsb vsps, *vsp;
static pthread_mutex_t panicstr_mtx = PTHREAD_MUTEX_INITIALIZER;
+/* Initialized in mgt_shmem.c, points into VSM */
+char *PAN_panicstr;
+unsigned PAN_panicstr_len;
+
/*--------------------------------------------------------------------*/
static void
@@ -354,20 +356,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
VSB_bcat(vsp, "", 1); /* NUL termination */
if (cache_param->diag_bitmap & 0x4000)
- (void)fputs(VSM_head->panicstr, stderr);
-
-#ifdef HAVE_ABORT2
- if (cache_param->diag_bitmap & 0x8000) {
- void *arg[1];
- char *p;
-
- for (p = VSM_head->panicstr; *p; p++)
- if (*p == '\n')
- *p = ' ';
- arg[0] = VSM_head->panicstr;
- abort2(VSM_head->panicstr, 1, arg);
- }
-#endif
+ (void)fputs(PAN_panicstr, stderr);
+
if (cache_param->diag_bitmap & 0x1000)
exit(4);
else
@@ -382,6 +372,8 @@ PAN_Init(void)
VAS_Fail = pan_ic;
vsp = &vsps;
- AN(VSB_new(vsp, VSM_head->panicstr, sizeof VSM_head->panicstr,
+ AN(PAN_panicstr);
+ AN(PAN_panicstr_len);
+ AN(VSB_new(vsp, PAN_panicstr, PAN_panicstr_len,
VSB_FIXEDLEN));
}
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 1252fa3..e004896 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -317,7 +317,6 @@ VSL_Init(void)
vsl_wrap();
VSM_head->starttime = (intmax_t)VTIM_real();
- memset(VSM_head->panicstr, '\0', sizeof *VSM_head->panicstr);
memset(VSC_C_main, 0, sizeof *VSC_C_main);
VSM_head->child_pid = getpid();
}
diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h
index f6d01db..f59cfc9 100644
--- a/bin/varnishd/common/common.h
+++ b/bin/varnishd/common/common.h
@@ -50,6 +50,9 @@ extern pid_t mgt_pid;
/* mgt_shmem.c */
extern struct VSC_C_main *VSC_C_main;
+#define PAN_CLASS "Panic"
+extern char *PAN_panicstr;
+extern unsigned PAN_panicstr_len;
/* varnishd.c */
struct vsb;
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 7e60c1a..b619b66 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -47,7 +47,6 @@
#include "common/heritage.h"
#include "common/params.h"
-#include "vapi/vsm_int.h"
#include "vbm.h"
#include "vcli.h"
#include "vcli_priv.h"
@@ -428,10 +427,10 @@ mgt_handle_panicstr(pid_t r)
{
char time_str[30];
- if (VSM_head->panicstr[0] == '\0')
+ if (PAN_panicstr[0] == '\0')
return;
REPORT(LOG_ERR, "Child (%jd) Panic message: %s",
- (intmax_t)r, VSM_head->panicstr);
+ (intmax_t)r, PAN_panicstr);
if (child_panic)
VSB_delete(child_panic);
@@ -439,7 +438,7 @@ mgt_handle_panicstr(pid_t r)
XXXAN(child_panic);
VTIM_format(VTIM_real(), time_str);
VSB_printf(child_panic, "Last panic at: %s\n", time_str);
- VSB_cat(child_panic, VSM_head->panicstr);
+ VSB_cat(child_panic, PAN_panicstr);
AZ(VSB_finish(child_panic));
}
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index afaab84..b7c18b2 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -843,9 +843,6 @@ static const struct parspec input_parspec[] = {
" 0x00001000 - do not core-dump child process.\n"
" 0x00002000 - only short panic message.\n"
" 0x00004000 - panic to stderr.\n"
-#ifdef HAVE_ABORT2
- " 0x00008000 - panic to abort2().\n"
-#endif
" 0x00010000 - synchronize shmlog.\n"
" 0x00020000 - synchronous start of persistence.\n"
" 0x00040000 - release VCL early.\n"
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index d4346df..24bc396 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -331,6 +331,12 @@ mgt_SHM_Init(const char *l_arg)
vsl_log_start[1] = VSL_ENDMARKER;
VWMB();
+ PAN_panicstr_len = 64 * 1024;
+ PAN_panicstr = VSM_Alloc(PAN_panicstr_len, PAN_CLASS, "", "");
+ AN(PAN_panicstr);
+ /* XXX: shouldn't VSM_Alloc zero ? */
+ memset(PAN_panicstr, '\0', PAN_panicstr_len);
+
do
*vsl_log_start = random() & 0xffff;
while (*vsl_log_start == 0);
diff --git a/configure.ac b/configure.ac
index bbe44b5..8404de4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,7 +187,6 @@ AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([strptime])
AC_CHECK_FUNCS([fmtcheck])
AC_CHECK_FUNCS([getdtablesize])
-AC_CHECK_FUNCS([abort2])
AC_CHECK_FUNCS([timegm])
AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([setppriv])
diff --git a/include/vapi/vsm_int.h b/include/vapi/vsm_int.h
index 3554982..521f89d 100644
--- a/include/vapi/vsm_int.h
+++ b/include/vapi/vsm_int.h
@@ -65,9 +65,6 @@ struct VSM_head {
unsigned shm_size;
- /* Panic message buffer */
- char panicstr[64 * 1024];
-
unsigned alloc_seq;
/* Must be last element */
struct VSM_chunk head;
More information about the varnish-commit
mailing list