[master] a1cdab1 Remove struct sess entirely from bgthreads
Poul-Henning Kamp
phk at varnish-cache.org
Sun Feb 19 13:16:49 CET 2012
commit a1cdab139ba08adcd6703aa96042036b1fa39a6a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sun Feb 19 12:16:38 2012 +0000
Remove struct sess entirely from bgthreads
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f722e7e..c4efc49 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -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);
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index e72343b..2c95f61 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -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;
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 90702f8..8eedb71 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -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);
}
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 6862a1f..d28a58c 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -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");
diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c
index 9edef51..535661e 100644
--- a/bin/varnishd/hash/hash_critbit.c
+++ b/bin/varnishd/hash/hash_critbit.c
@@ -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;
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 5e2db82..58c6f29 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -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);
More information about the varnish-commit
mailing list