[5.2] 0efecdc Move the sigaltstack init to a generic THR_Init() and use it for all threads
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Fri Sep 15 11:17:16 UTC 2017
commit 0efecdc9cb25234560b9b397db27a53f226ca526
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Sep 11 12:34:32 2017 +0200
Move the sigaltstack init to a generic THR_Init() and use it for all threads
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 91f5c08..8da85ae 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -524,6 +524,7 @@ vca_acct(void *arg)
double t0, now;
THR_SetName("cache-acceptor");
+ THR_Init();
(void)arg;
(void)vca_tcp_opt_init();
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index 8602fcf..684d456 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -113,6 +113,22 @@ THR_GetName(void)
}
/*--------------------------------------------------------------------
+ * Generic setup all our threads should call
+ */
+#ifdef HAVE_SIGALTSTACK
+#include <signal.h>
+extern stack_t altstack;
+#endif
+
+void
+THR_Init(void)
+{
+#ifdef HAVE_SIGALTSTACK
+ AZ(sigaltstack(&altstack, NULL));
+#endif
+}
+
+/*--------------------------------------------------------------------
* VXID's are unique transaction numbers allocated with a minimum of
* locking overhead via pools in the worker threads.
*
diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c
index 98c22f0..0e05bcc 100644
--- a/bin/varnishd/cache/cache_mempool.c
+++ b/bin/varnishd/cache/cache_mempool.c
@@ -104,6 +104,7 @@ mpl_guard(void *priv)
CAST_OBJ_NOTNULL(mpl, priv, MEMPOOL_MAGIC);
THR_SetName(mpl->name);
+ THR_Init();
mpl_slp = 0.15; // random
while (1) {
VTIM_sleep(mpl_slp);
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index 0bf34f2..595e836 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -187,6 +187,7 @@ pool_poolherder(void *priv)
void *rvp;
THR_SetName("pool_poolherder");
+ THR_Init();
(void)priv;
nwq = 0;
diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h
index 941d567..18bb141 100644
--- a/bin/varnishd/cache/cache_priv.h
+++ b/bin/varnishd/cache/cache_priv.h
@@ -88,6 +88,7 @@ void THR_SetBusyobj(const struct busyobj *);
struct busyobj * THR_GetBusyobj(void);
void THR_SetRequest(const struct req *);
struct req * THR_GetRequest(void);
+void THR_Init(void);
/* cache_lck.c */
void LCK_Init(void);
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index cf2948b..8735929 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -41,11 +41,6 @@
#include "hash/hash_slinger.h"
-#ifdef HAVE_SIGALTSTACK
-#include <signal.h>
-extern stack_t altstack;
-#endif
-
static void Pool_Work_Thread(struct pool *pp, struct worker *wrk);
/*--------------------------------------------------------------------
@@ -70,6 +65,7 @@ wrk_bgthread(void *arg)
CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC);
THR_SetName(bt->name);
+ THR_Init();
INIT_OBJ(&wrk, WORKER_MAGIC);
memset(&ds, 0, sizeof ds);
wrk.stats = &ds;
@@ -406,9 +402,7 @@ pool_thread(void *priv)
struct pool_info *pi;
CAST_OBJ_NOTNULL(pi, priv, POOL_INFO_MAGIC);
-#ifdef HAVE_SIGALTSTACK
- AZ(sigaltstack(&altstack, NULL));
-#endif
+ THR_Init();
WRK_Thread(pi->qp, pi->stacksize, cache_param->workspace_thread);
FREE_OBJ(pi);
return (NULL);
@@ -483,6 +477,7 @@ pool_herder(void *priv)
CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC);
THR_SetName("pool_herder");
+ THR_Init();
while (!pp->die || pp->nthr > 0) {
wthread_min = cache_param->wthread_min;
diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c
index 5c40597..358d2be 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -80,6 +80,7 @@ vwe_thread(void *priv)
w = vwe->waiter;
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
THR_SetName("cache-epoll");
+ THR_Init();
now = VTIM_real();
while (1) {
diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c
index 5d06b2d..ff870e7 100644
--- a/bin/varnishd/waiter/cache_waiter_kqueue.c
+++ b/bin/varnishd/waiter/cache_waiter_kqueue.c
@@ -75,6 +75,7 @@ vwk_thread(void *priv)
w = vwk->waiter;
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
THR_SetName("cache-kqueue");
+ THR_Init();
now = VTIM_real();
while (1) {
diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c
index ee70140..52e4de3 100644
--- a/bin/varnishd/waiter/cache_waiter_poll.c
+++ b/bin/varnishd/waiter/cache_waiter_poll.c
@@ -161,6 +161,7 @@ vwp_main(void *priv)
int i;
THR_SetName("cache-poll");
+ THR_Init();
CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC);
w = vwp->waiter;
diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c
index b7259bf..3a1dc49 100644
--- a/bin/varnishd/waiter/cache_waiter_ports.c
+++ b/bin/varnishd/waiter/cache_waiter_ports.c
@@ -152,6 +152,7 @@ vws_thread(void *priv)
w = vws->waiter;
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
THR_SetName("cache-ports");
+ THR_Init();
now = VTIM_real();
More information about the varnish-commit
mailing list