buffer.
Replace the default libvarnish assert handler with a child specific
function.
This function which fills the static panic string and copy the
result to the shared memory panicstring.
In the manager process, report the content of the panic string
when the child dies.
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2971
d4fa192b-c00b-0410-8231-
f00ffab90ce4
void THR_SetSession(const struct sess *sp);
const struct sess * THR_GetSession(void);
+/* cache_panic.c */
+void PAN_Init(void);
+
/* cache_pipe.c */
void PipeSession(struct sess *sp);
void SES_Charge(struct sess *sp);
/* cache_shmlog.c */
-
void VSL_Init(void);
#ifdef SHMLOGHEAD_MAGIC
void VSL(enum shmlogtag tag, int id, const char *fmt, ...);
THR_Name("cache-main");
+ PAN_Init();
CLI_Init();
Fetch_Init();
* (gdb) printf "%s", panicstr
*/
char panicstr[65536];
+static struct vsb vsps, *vsp;
+
static char *pstr = panicstr;
#define fp(...) \
}
#endif
+
+static void
+pan_ic(const char *func, const char *file, int line, const char *cond, int err, int xxx)
+{
+ int l;
+ char *p;
+
+ if (xxx) {
+ vsb_printf(vsp,
+ "Missing errorhandling code in %s(), %s line %d:\n"
+ " Condition(%s) not true.\n",
+ func, file, line, cond);
+ } else {
+ vsb_printf(vsp,
+ "Assert error in %s(), %s line %d:\n"
+ " Condition(%s) not true.\n",
+ func, file, line, cond);
+ }
+ if (err)
+ vsb_printf(vsp,
+ " errno = %d (%s)\n", err, strerror(err));
+
+ VSL_Panic(&l, &p);
+ if (l < vsb_len(vsp))
+ l = vsb_len(vsp);
+ memcpy(p, panicstr, l);
+ abort();
+}
+
+
+void
+PAN_Init(void)
+{
+
+ lbv_assert = pan_ic;
+ vsp = &vsps;
+ AN(vsb_new(vsp, panicstr, sizeof panicstr, VSB_FIXEDLEN));
+}
/* cache_acceptor.c */
void VCA_tweak_acceptor(struct cli *cli, const char *arg);
+/* shmlog.c */
+void VSL_Panic(int *len, char **ptr);
/* shmlog.c */
void VSL_MgtInit(const char *fn, unsigned size);
/*--------------------------------------------------------------------*/
+static void
+mgt_report_panic(pid_t r)
+{
+ int l;
+ char *p;
+
+ VSL_Panic(&l, &p);
+ if (*p == '\0')
+ return;
+ REPORT(LOG_ERR, "Child (%d) Panic message: %s", r, p);
+}
+
+/*--------------------------------------------------------------------*/
+
static int
mgt_sigchld(const struct vev *e, int what)
{
REPORT(LOG_INFO, "%s", vsb_data(vsb));
vsb_delete(vsb);
+ mgt_report_panic(r);
+
child_pid = -1;
if (child_state == CH_RUNNING) {
/*--------------------------------------------------------------------*/
+void
+VSL_Panic(int *len, char **ptr)
+{
+
+ AN(len);
+ AN(ptr);
+ assert(loghead->magic == SHMLOGHEAD_MAGIC);
+ assert(loghead->hdrsize == sizeof *loghead);
+ *len = sizeof(loghead->panicstr);
+ *ptr = loghead->panicstr;
+}
+
+/*--------------------------------------------------------------------*/
+
void
VSL_Init(void)
{
logstart = (unsigned char *)loghead + loghead->start;
MTX_INIT(&vsl_mtx);
loghead->starttime = TIM_real();
+ loghead->panicstr[0] = '\0';
memset(VSL_stats, 0, sizeof *VSL_stats);
}
unsigned ptr;
struct varnish_stats stats;
+
+ /* Panic message buffer */
+ char panicstr[64 * 1024];
};
/*