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

Remove struct sess entirely from bgthreads

parent e6327393
......@@ -981,7 +981,7 @@ void WRK_Init(void);
int WRK_TrySumStat(struct worker *w);
void WRK_SumStat(struct worker *w);
void *WRK_thread(void *priv);
typedef void *bgthread_t(struct sess *, void *priv);
typedef void *bgthread_t(struct worker *, void *priv);
void WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func,
void *priv);
......
......@@ -927,7 +927,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass)
}
static void * __match_proto__(bgthread_t)
ban_lurker(struct sess *sp, void *priv)
ban_lurker(struct worker *wrk, void *priv)
{
struct ban *bf;
unsigned pass = (1 << LURK_SHIFT);
......@@ -950,9 +950,9 @@ ban_lurker(struct sess *sp, void *priv)
VTIM_sleep(1.0);
}
i = ban_lurker_work(sp->wrk, pass);
VSL_Flush(sp->wrk->vsl, 0);
WRK_SumStat(sp->wrk);
i = ban_lurker_work(wrk, pass);
VSL_Flush(wrk->vsl, 0);
WRK_SumStat(wrk);
if (i) {
pass += (1 << LURK_SHIFT);
pass &= BAN_F_LURK;
......
......@@ -330,7 +330,7 @@ EXP_Rearm(const struct object *o)
*/
static void * __match_proto__(bgthread_t)
exp_timer(struct sess *sp, void *priv)
exp_timer(struct worker *wrk, void *priv)
{
struct objcore *oc;
struct lru *lru;
......@@ -342,8 +342,8 @@ exp_timer(struct sess *sp, void *priv)
oc = NULL;
while (1) {
if (oc == NULL) {
VSL_Flush(sp->wrk->vsl, 0);
WRK_SumStat(sp->wrk);
VSL_Flush(wrk->vsl, 0);
WRK_SumStat(wrk);
VTIM_sleep(cache_param->expiry_sleep);
t = VTIM_real();
}
......@@ -399,10 +399,10 @@ exp_timer(struct sess *sp, void *priv)
VSC_C_main->n_expired++;
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
o = oc_getobj(&sp->wrk->stats, oc);
WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f",
oc_getxid(&sp->wrk->stats, oc), EXP_Ttl(NULL, o) - t);
(void)HSH_Deref(&sp->wrk->stats, oc, NULL);
o = oc_getobj(&wrk->stats, oc);
WSL(wrk->vsl, SLT_ExpKill, 0, "%u %.0f",
oc_getxid(&wrk->stats, oc), EXP_Ttl(NULL, o) - t);
(void)HSH_Deref(&wrk->stats, oc, NULL);
}
NEEDLESS_RETURN(NULL);
}
......
......@@ -94,19 +94,15 @@ wrk_bgthread(void *arg)
{
struct bgthread *bt;
struct worker wrk;
struct sess *sp;
uint32_t logbuf[1024]; /* XXX: size ? */
CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC);
THR_SetName(bt->name);
sp = SES_Alloc();
XXXAN(sp);
memset(&wrk, 0, sizeof wrk);
sp->wrk = &wrk;
wrk.magic = WORKER_MAGIC;
VSL_Setup(wrk.vsl, logbuf, sizeof logbuf);
(void)bt->func(sp, bt->priv);
(void)bt->func(&wrk, bt->priv);
WRONG("BgThread terminated");
......
......@@ -345,10 +345,9 @@ static struct cli_proto hcb_cmds[] = {
/*--------------------------------------------------------------------*/
static void * __match_proto__(bgthread_t)
hcb_cleaner(struct sess *sp, void *priv)
hcb_cleaner(struct worker *wrk, void *priv)
{
struct hcb_y *y, *y2;
struct worker *wrk = sp->wrk;
struct objhead *oh, *oh2;
(void)priv;
......
......@@ -268,18 +268,18 @@ smp_open_segs(struct smp_sc *sc, struct smp_signctx *ctx)
*/
static void * __match_proto__(bgthread_t)
smp_thread(struct sess *sp, void *priv)
smp_thread(struct worker *wrk, void *priv)
{
struct smp_sc *sc;
struct smp_seg *sg;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC);
/* First, load all the objects from all segments */
VTAILQ_FOREACH(sg, &sc->segments, list)
if (sg->flags & SMP_SEG_MUSTLOAD)
smp_load_seg(sp->wrk, sc, sg);
smp_load_seg(wrk, sc, sg);
sc->flags |= SMP_SC_LOADED;
BAN_TailDeref(&sc->tailban);
......@@ -288,8 +288,7 @@ smp_thread(struct sess *sp, void *priv)
while (1) {
(void)sleep (1);
sg = VTAILQ_FIRST(&sc->segments);
if (sg != NULL && sg -> sc->cur_seg &&
sg->nobj == 0) {
if (sg != NULL && sg -> sc->cur_seg && sg->nobj == 0) {
Lck_Lock(&sc->mtx);
smp_save_segs(sc);
Lck_Unlock(&sc->mtx);
......
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