r2293 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Dec 11 10:03:51 CET 2007
Author: phk
Date: 2007-12-11 10:03:51 +0100 (Tue, 11 Dec 2007)
New Revision: 2293
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_expire.c
trunk/varnish-cache/bin/varnishd/cache_main.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
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.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-12-11 09:03:51 UTC (rev 2293)
@@ -506,6 +506,9 @@
#include "http_headers.h"
#undef HTTPH
+/* cache_main.c */
+void THR_Name(const char *name);
+
/* cache_pipe.c */
void PipeSession(struct sess *sp);
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-12-11 09:03:51 UTC (rev 2293)
@@ -154,6 +154,7 @@
unsigned u;
double now;
+ THR_Name("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 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-12-11 09:03:51 UTC (rev 2293)
@@ -73,6 +73,7 @@
struct sess *sp, *sp2;
int i;
+ THR_Name("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 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-12-11 09:03:51 UTC (rev 2293)
@@ -233,6 +233,7 @@
double deadline;
struct sess *sp;
+ THR_Name("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 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-12-11 09:03:51 UTC (rev 2293)
@@ -112,6 +112,7 @@
double deadline;
int i, fd;
+ THR_Name("cache-poll");
(void)arg;
vca_poll(vca_pipes[0]);
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-12-11 09:03:51 UTC (rev 2293)
@@ -114,6 +114,7 @@
struct object *o;
double t;
+ THR_Name("cache-hangman");
(void)arg;
t = TIM_real();
@@ -167,6 +168,7 @@
struct object *o2;
unsigned char log[1024]; /* XXX size ? */
+ THR_Name("cache-timeout");
(void)arg;
sp = SES_New(NULL, 0);
Modified: trunk/varnish-cache/bin/varnishd/cache_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_main.c 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache_main.c 2007-12-11 09:03:51 UTC (rev 2293)
@@ -40,6 +40,27 @@
#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 @@
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);
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-12-11 09:02:29 UTC (rev 2292)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-12-11 09:03:51 UTC (rev 2293)
@@ -205,6 +205,7 @@
char c;
unsigned char wlog[8192]; /* XXX: size */
+ THR_Name("cache-worker");
w = &ww;
qp = priv;
memset(w, 0, sizeof *w);
More information about the varnish-commit
mailing list