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