Commit 421ebab3 authored by Nils Goroll's avatar Nils Goroll

Move the sigaltstack init to a generic THR_Init() and use it for all threads

parent 35ffe6a6
......@@ -524,6 +524,7 @@ vca_acct(void *arg)
double t0, now;
THR_SetName("cache-acceptor");
THR_Init();
(void)arg;
(void)vca_tcp_opt_init();
......
......@@ -112,6 +112,22 @@ THR_GetName(void)
return (pthread_getspecific(name_key));
}
/*--------------------------------------------------------------------
* 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.
......
......@@ -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);
......
......@@ -187,6 +187,7 @@ pool_poolherder(void *priv)
void *rvp;
THR_SetName("pool_poolherder");
THR_Init();
(void)priv;
nwq = 0;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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();
......
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