Commit dea1f50b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Attempt to name threads if possible.

On FreeBSD this means that for instance "top -H" will show the
varnish threads as "cache-foo" for various values of foo, hopefully
giving us another debugging hint.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2293 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 54ccb911
......@@ -506,6 +506,9 @@ int HTC_Complete(struct http_conn *htc);
#include "http_headers.h"
#undef HTTPH
/* cache_main.c */
void THR_Name(const char *name);
/* cache_pipe.c */
void PipeSession(struct sess *sp);
......
......@@ -154,6 +154,7 @@ vca_acct(void *arg)
unsigned u;
double now;
THR_Name("cache-acceptor");
(void)arg;
/* Set up the poll argument */
......
......@@ -73,6 +73,7 @@ vca_main(void *arg)
struct sess *sp, *sp2;
int i;
THR_Name("cache-epoll");
(void)arg;
epfd = epoll_create(16);
......
......@@ -233,6 +233,7 @@ vca_kqueue_main(void *arg)
double deadline;
struct sess *sp;
THR_Name("cache-kqueue");
(void)arg;
kq = kqueue();
......
......@@ -112,6 +112,7 @@ vca_main(void *arg)
double deadline;
int i, fd;
THR_Name("cache-poll");
(void)arg;
vca_poll(vca_pipes[0]);
......
......@@ -114,6 +114,7 @@ exp_hangman(void *arg)
struct object *o;
double t;
THR_Name("cache-hangman");
(void)arg;
t = TIM_real();
......@@ -167,6 +168,7 @@ exp_prefetch(void *arg)
struct object *o2;
unsigned char log[1024]; /* XXX size ? */
THR_Name("cache-timeout");
(void)arg;
sp = SES_New(NULL, 0);
......
......@@ -39,6 +39,27 @@
#include "heritage.h"
#include "stevedore.h"
/*--------------------------------------------------------------------
* Name threads if our pthreads implementation supports it.
*/
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
void
THR_Name(const char *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
}
/*--------------------------------------------------------------------
* XXX: Think more about which order we start things
*/
......@@ -51,6 +72,8 @@ child_main(void)
setbuf(stderr, NULL);
printf("Child starts\n");
THR_Name("cache-main");
#define SZOF(foo) printf("sizeof(%s) = %zd\n", #foo, sizeof(foo));
SZOF(struct ws);
SZOF(struct http);
......
......@@ -205,6 +205,7 @@ wrk_thread(void *priv)
char c;
unsigned char wlog[8192]; /* XXX: size */
THR_Name("cache-worker");
w = &ww;
qp = priv;
memset(w, 0, sizeof *w);
......
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