Commit 9245f686 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add an ident-string to panic output, which reveals arch,os,rev and which

subsystems are used (storage/hash/waiter) but not the options given to
these.

This info is often missing in bugreports.



git-svn-id: http://www.varnish-cache.org/svn/trunk@4481 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent dc46ec07
......@@ -446,6 +446,7 @@ void vca_return_session(struct sess *sp);
void vca_close_session(struct sess *sp, const char *why);
void VCA_Prep(struct sess *sp);
void VCA_Init(void);
const char *VCA_waiter_name(void);
extern pthread_t VCA_thread;
/* cache_backend.c */
......
......@@ -70,7 +70,22 @@ pthread_t VCA_thread;
static struct timeval tv_sndtimeo;
static struct timeval tv_rcvtimeo;
/*
/*--------------------------------------------------------------------
* Report waiter name to panics
*/
const char *
VCA_waiter_name(void)
{
if (vca_act != NULL)
return (vca_act->name);
else
return ("no_waiter");
}
/*--------------------------------------------------------------------
* We want to get out of any kind of touble-hit TCP connections as fast
* as absolutely possible, so we set them LINGER enabled with zero timeout,
* so that even if there are outstanding write data on the socket, a close(2)
......@@ -395,6 +410,8 @@ VCA_tweak_waiter(struct cli *cli, const char *arg)
{
int i;
ASSERT_MGT();
if (arg == NULL) {
if (vca_act == NULL)
cli_out(cli, "default");
......
......@@ -326,6 +326,9 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
if (q != NULL)
vsb_printf(vsp, "thread = (%s)\n", q);
vsb_printf(vsp, "ident = %s,%s\n",
vsb_data(vident) + 1, VCA_waiter_name());
pan_backtrace();
if (!(params->diag_bitmap & 0x2000)) {
......
......@@ -31,6 +31,7 @@
struct cli;
struct sockaddr;
extern pid_t mgt_pid;
#define ASSERT_MGT() do { assert(getpid() == mgt_pid);} while (0)
......@@ -46,6 +47,7 @@ extern struct varnish_stats *VSL_stats;
/* varnishd.c */
struct vsb;
extern struct vsb *vident;
int Symbol_Lookup(struct vsb *vsb, void *ptr);
#define TRUST_ME(ptr) ((void*)(uintptr_t)(ptr))
......
......@@ -49,6 +49,8 @@ SVNID("$Id$")
#include <time.h>
#include <unistd.h>
#include <sys/utsname.h>
#include "compat/daemon.h"
#ifndef HAVE_STRLCPY
......@@ -81,6 +83,21 @@ unsigned d_flag = 0;
pid_t mgt_pid;
struct vev_base *mgt_evb;
int exit_status = 0;
struct vsb *vident;
static void
build_vident(void)
{
struct utsname uts;
vident = vsb_newauto();
AN(vident);
if (!uname(&uts)) {
vsb_printf(vident, ",%s", uts.sysname);
vsb_printf(vident, ",%s", uts.release);
vsb_printf(vident, ",%s", uts.machine);
}
}
/*--------------------------------------------------------------------*/
......@@ -132,6 +149,7 @@ setup_storage(const char *spec)
priv = pick(STV_choice, av[1], "storage");
AN(priv);
vsb_printf(vident, ",-s%s", av[1]);
STV_add(priv, ac, av + 2);
......@@ -161,6 +179,7 @@ setup_hash(const char *h_arg)
hp = pick(hsh_choice, av[1], "hash");
CHECK_OBJ_NOTNULL(hp, SLINGER_MAGIC);
vsb_printf(vident, ",-h%s", av[1]);
heritage.hash = hp;
if (hp->init != NULL)
hp->init(ac, av + 2);
......@@ -526,6 +545,8 @@ main(int argc, char * const *argv)
setbuf(stdout, NULL);
setbuf(stderr, NULL);
build_vident();
Symbol_hack(argv[0]);
/* for ASSERT_MGT() */
......@@ -734,6 +755,9 @@ main(int argc, char * const *argv)
VSL_MgtInit(SHMLOG_FILENAME, l_size);
vsb_finish(vident);
AZ(vsb_overflowed(vident));
if (d_flag == 1)
DebugStunt();
if (d_flag < 2 && !F_flag)
......@@ -744,6 +768,9 @@ main(int argc, char * const *argv)
if (pfh != NULL && vpf_write(pfh))
fprintf(stderr, "NOTE: Could not write PID file\n");
if (d_flag > 0)
fprintf(stderr, "Varnish on %s\n", vsb_data(vident) + 1);
/* Do this again after debugstunt and daemon has run */
mgt_pid = getpid();
......
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