r2972 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Sun Jul 20 12:45:09 CEST 2008
Author: phk
Date: 2008-07-20 12:45:09 +0200 (Sun, 20 Jul 2008)
New Revision: 2972
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
trunk/varnish-cache/bin/varnishd/cache_expire.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_main.c
trunk/varnish-cache/bin/varnishd/cache_panic.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Report thread name and thread session in panic messages.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2008-07-20 10:45:09 UTC (rev 2972)
@@ -510,7 +510,8 @@
#undef HTTPH
/* cache_main.c */
-void THR_Name(const char *name);
+void THR_SetName(const char *name);
+const char* THR_GetName(void);
void THR_SetSession(const struct sess *sp);
const struct sess * THR_GetSession(void);
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -162,7 +162,7 @@
unsigned u;
double now;
- THR_Name("cache-acceptor");
+ THR_SetName("cache-acceptor");
(void)arg;
/* Set up the poll argument */
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -76,7 +76,7 @@
struct sess *sp, *sp2;
int i;
- THR_Name("cache-epoll");
+ THR_SetName("cache-epoll");
(void)arg;
epfd = epoll_create(16);
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -152,7 +152,7 @@
double deadline;
struct sess *sp;
- THR_Name("cache-kqueue");
+ THR_SetName("cache-kqueue");
(void)arg;
kq = kqueue();
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -111,7 +111,7 @@
double deadline;
int i, fd;
- THR_Name("cache-poll");
+ THR_SetName("cache-poll");
(void)arg;
vca_poll(vca_pipes[0]);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -68,7 +68,7 @@
(void)w;
CAST_OBJ_NOTNULL(vt, priv, VBP_TARGET_MAGIC);
- THR_Name("backend poll");
+ THR_SetName("backend poll");
while (!vt->stop) {
printf("Poke backend %s\n", vt->backend->vcl_name);
@@ -76,7 +76,7 @@
}
vt->backend->probe = NULL;
FREE_OBJ(vt);
- THR_Name("cache-worker");
+ THR_SetName("cache-worker");
}
void
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -263,7 +263,7 @@
struct sess *sp;
unsigned char logbuf[1024]; /* XXX size ? */
- THR_Name("cache-timeout");
+ THR_SetName("cache-timeout");
(void)arg;
sp = SES_New(NULL, 0);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -317,6 +317,7 @@
struct http_conn htc[1];
int i;
+AZ(sp);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
Modified: trunk/varnish-cache/bin/varnishd/cache_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_main.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_main.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -65,19 +65,25 @@
* Name threads if our pthreads implementation supports it.
*/
+static pthread_key_t name_key;
+
void
-THR_Name(const char *name)
+THR_SetName(const char *name)
{
+
+ AZ(pthread_setspecific(name_key, name));
#ifdef HAVE_PTHREAD_SET_NAME_NP
pthread_set_name_np(pthread_self(), name);
-#else
- /*
- * XXX: we could stash it somewhere else (TLS ?)
- */
- (void)name;
#endif
}
+const char *
+THR_GetName(void)
+{
+
+ return (pthread_getspecific(name_key));
+}
+
/*--------------------------------------------------------------------
* XXX: Think more about which order we start things
*/
@@ -91,8 +97,9 @@
printf("Child starts\n");
AZ(pthread_key_create(&sp_key, NULL));
+ AZ(pthread_key_create(&name_key, NULL));
- THR_Name("cache-main");
+ THR_SetName("cache-main");
PAN_Init();
CLI_Init();
Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_panic.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_panic.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -248,22 +248,30 @@
{
int l;
char *p;
+ const char *q;
+ const struct sess *sp;
if (xxx) {
vsb_printf(vsp,
"Missing errorhandling code in %s(), %s line %d:\n"
- " Condition(%s) not true.\n",
+ " Condition(%s) not true.",
func, file, line, cond);
} else {
vsb_printf(vsp,
"Assert error in %s(), %s line %d:\n"
- " Condition(%s) not true.\n",
+ " Condition(%s) not true.",
func, file, line, cond);
}
if (err)
- vsb_printf(vsp,
- " errno = %d (%s)\n", err, strerror(err));
+ vsb_printf(vsp, " errno = %d (%s)", err, strerror(err));
+ q = THR_GetName();
+ if (q != NULL)
+ vsb_printf(vsp, " thread = (%s)", q);
+ sp = THR_GetSession();
+ if (sp != NULL)
+ vsb_printf(vsp, " sess = (%p)", sp);
+ vsb_printf(vsp, "\n");
VSL_Panic(&l, &p);
if (l < vsb_len(vsp))
l = vsb_len(vsp);
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-07-20 10:36:28 UTC (rev 2971)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-07-20 10:45:09 UTC (rev 2972)
@@ -208,7 +208,7 @@
unsigned char wlog[8192]; /* XXX: size */
struct workreq *wrq;
- THR_Name("cache-worker");
+ THR_SetName("cache-worker");
w = &ww;
CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC);
memset(w, 0, sizeof *w);
@@ -441,7 +441,7 @@
double t_idle;
struct varnish_stats vsm, *vs;
- THR_Name("wrk_herdtimer");
+ THR_SetName("wrk_herdtimer");
memset(&vsm, 0, sizeof vsm);
vs = &vsm;
@@ -534,7 +534,7 @@
{
unsigned u, w;
- THR_Name("wrk_herder");
+ THR_SetName("wrk_herder");
(void)priv;
while (1) {
for (u = 0 ; u < nwq; u++) {
More information about the varnish-commit
mailing list