[master] 219aa02 Eliminate struct sess from HSH_Insert()

Poul-Henning Kamp phk at varnish-cache.org
Sun Feb 19 12:58:34 CET 2012


commit 219aa0297024653698319efa5750a19f3dccc116
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Feb 19 11:58:19 2012 +0000

    Eliminate struct sess from HSH_Insert()

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index a9ff554..a022cbe 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -800,7 +800,7 @@ ban_CheckLast(void)
  * Ban lurker thread
  */
 
-static int
+static int __match_proto__(bgthread_t)
 ban_lurker_work(const struct sess *sp, unsigned pass)
 {
 	struct ban *b, *b0, *b2;
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index e0f3d27..90702f8 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -329,7 +329,7 @@ EXP_Rearm(const struct object *o)
  * object expires, accounting also for graceability, it is killed.
  */
 
-static void * __match_proto__(void *start_routine(void *))
+static void * __match_proto__(bgthread_t)
 exp_timer(struct sess *sp, void *priv)
 {
 	struct objcore *oc;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index ce596df..15b0a2a 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -245,26 +245,21 @@ hsh_testmagic(void *result)
  */
 
 void
-HSH_Insert(const struct sess *sp, const void *digest, struct objcore *oc)
+HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc)
 {
-	struct worker *wrk;
 	struct objhead *oh;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	AN(digest);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
-	wrk = sp->wrk;
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-
 	hsh_prealloc(wrk);
 	if (cache_param->diag_bitmap & 0x80000000)
 		hsh_testmagic(wrk->nobjhead->digest);
 
-	AZ(sp->req);
 	AN(wrk->nobjhead);
 	memcpy(wrk->nobjhead->digest, digest, SHA256_LEN);
-	oh = hash->lookup(sp, wrk->nobjhead);
+	oh = hash->lookup(wrk, wrk->nobjhead);
 	CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
 	if (oh == wrk->nobjhead)
 		wrk->nobjhead = NULL;
@@ -320,7 +315,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 		sp->req->hash_objhead = NULL;
 	} else {
 		AN(wrk->nobjhead);
-		oh = hash->lookup(sp, wrk->nobjhead);
+		oh = hash->lookup(wrk, wrk->nobjhead);
 		if (oh == wrk->nobjhead)
 			wrk->nobjhead = NULL;
 	}
diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c
index b530f25..c84238a 100644
--- a/bin/varnishd/hash/hash_classic.c
+++ b/bin/varnishd/hash/hash_classic.c
@@ -54,7 +54,7 @@ static struct hcl_hd		*hcl_head;
  * The ->init method allows the management process to pass arguments
  */
 
-static void
+static void __match_proto__(hash_init_f)
 hcl_init(int ac, char * const *av)
 {
 	int i;
@@ -86,7 +86,7 @@ hcl_init(int ac, char * const *av)
  * initialization to happen before the first lookup.
  */
 
-static void
+static void __match_proto__(hash_start_f)
 hcl_start(void)
 {
 	unsigned u;
@@ -110,15 +110,15 @@ hcl_start(void)
  * rare and collisions even rarer.
  */
 
-static struct objhead *
-hcl_lookup(const struct sess *sp, struct objhead *noh)
+static struct objhead * __match_proto__(hash_lookup_f)
+hcl_lookup(struct worker *wrk, struct objhead *noh)
 {
 	struct objhead *oh;
 	struct hcl_hd *hp;
 	unsigned u1, digest;
 	int i;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
 
 	assert(sizeof noh->digest > sizeof digest);
@@ -153,7 +153,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
  * Dereference and if no references are left, free.
  */
 
-static int
+static int __match_proto__(hash_deref_f)
 hcl_deref(struct objhead *oh)
 {
 	struct hcl_hd *hp;
diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c
index fbdc906..9edef51 100644
--- a/bin/varnishd/hash/hash_critbit.c
+++ b/bin/varnishd/hash/hash_critbit.c
@@ -373,7 +373,7 @@ hcb_cleaner(struct sess *sp, void *priv)
 
 /*--------------------------------------------------------------------*/
 
-static void
+static void __match_proto__(hash_start_f)
 hcb_start(void)
 {
 	struct objhead *oh = NULL;
@@ -387,7 +387,7 @@ hcb_start(void)
 	hcb_build_bittbl();
 }
 
-static int
+static int __match_proto__(hash_deref_f)
 hcb_deref(struct objhead *oh)
 {
 	int r;
@@ -412,28 +412,28 @@ hcb_deref(struct objhead *oh)
 	return (r);
 }
 
-static struct objhead *
-hcb_lookup(const struct sess *sp, struct objhead *noh)
+static struct objhead * __match_proto__(hash_lookup_f)
+hcb_lookup(struct worker *wrk, struct objhead *noh)
 {
 	struct objhead *oh;
 	struct hcb_y *y;
 	unsigned u;
 	unsigned with_lock;
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 
 	with_lock = 0;
 	while (1) {
 		if (with_lock) {
-			CAST_OBJ_NOTNULL(y, sp->wrk->nhashpriv, HCB_Y_MAGIC);
+			CAST_OBJ_NOTNULL(y, wrk->nhashpriv, HCB_Y_MAGIC);
 			Lck_Lock(&hcb_mtx);
 			VSC_C_main->hcb_lock++;
 			assert(noh->refcnt == 1);
-			oh = hcb_insert(sp->wrk, &hcb_root, noh, 1);
+			oh = hcb_insert(wrk, &hcb_root, noh, 1);
 			Lck_Unlock(&hcb_mtx);
 		} else {
 			VSC_C_main->hcb_nolock++;
-			oh = hcb_insert(sp->wrk, &hcb_root, noh, 0);
+			oh = hcb_insert(wrk, &hcb_root, noh, 0);
 		}
 
 		if (oh != NULL && oh == noh) {
@@ -468,7 +468,7 @@ hcb_lookup(const struct sess *sp, struct objhead *noh)
 	}
 }
 
-static void
+static void __match_proto__(hash_prep_f)
 hcb_prep(struct worker *wrk)
 {
 	struct hcb_y *y;
diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c
index c1cc9c8..fef2b65 100644
--- a/bin/varnishd/hash/hash_simple_list.c
+++ b/bin/varnishd/hash/hash_simple_list.c
@@ -45,7 +45,7 @@ static struct lock hsl_mtx;
  * initialization to happen before the first lookup.
  */
 
-static void
+static void __match_proto__(hash_start_f)
 hsl_start(void)
 {
 
@@ -59,13 +59,13 @@ hsl_start(void)
  * A reference to the returned object is held.
  */
 
-static struct objhead *
-hsl_lookup(const struct sess *sp, struct objhead *noh)
+static struct objhead * __match_proto__(hash_lookup_f)
+hsl_lookup(struct worker *wrk, struct objhead *noh)
 {
 	struct objhead *oh;
 	int i;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
 	Lck_Lock(&hsl_mtx);
 	VTAILQ_FOREACH(oh, &hsl_head, hoh_list) {
@@ -92,7 +92,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
  * Dereference and if no references are left, free.
  */
 
-static int
+static int __match_proto__(hash_deref_f)
 hsl_deref(struct objhead *oh)
 {
 	int ret;
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index 9add938..b15d9df 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -36,7 +36,7 @@ typedef void hash_init_f(int ac, char * const *av);
 typedef void hash_start_f(void);
 typedef void hash_prep_f(struct worker *);
 typedef struct objhead *
-    hash_lookup_f(const struct sess *sp, struct objhead *nobj);
+    hash_lookup_f(struct worker *wrk, struct objhead *nobj);
 typedef int hash_deref_f(struct objhead *obj);
 
 struct hash_slinger {
@@ -58,7 +58,7 @@ void HSH_Ref(struct objcore *o);
 void HSH_Drop(struct worker *, struct object **);
 void HSH_Init(const struct hash_slinger *slinger);
 void HSH_AddString(const struct sess *sp, const char *str);
-void HSH_Insert(const struct sess *sp, const void *hash, struct objcore *);
+void HSH_Insert(struct worker *, const void *hash, struct objcore *);
 void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace);
 void HSH_config(const char *h_arg);
 
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index c49ceac..5e2db82 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -267,19 +267,19 @@ smp_open_segs(struct smp_sc *sc, struct smp_signctx *ctx)
  * Silo worker thread
  */
 
-static void *
+static void * __match_proto__(bgthread_t)
 smp_thread(struct sess *sp, void *priv)
 {
 	struct smp_sc	*sc;
 	struct smp_seg *sg;
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(sp, SESS_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, sc, sg);
+			smp_load_seg(sp->wrk, sc, sg);
 
 	sc->flags |= SMP_SC_LOADED;
 	BAN_TailDeref(&sc->tailban);
diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h
index 84f3d21..a755b89 100644
--- a/bin/varnishd/storage/storage_persistent.h
+++ b/bin/varnishd/storage/storage_persistent.h
@@ -167,8 +167,7 @@ void smp_mgt_init(struct stevedore *parent, int ac, char * const *av);
 
 /* storage_persistent_silo.c */
 
-void smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
-    struct smp_seg *sg);
+void smp_load_seg(struct worker *, const struct smp_sc *sc, struct smp_seg *sg);
 void smp_new_seg(struct smp_sc *sc);
 void smp_close_seg(struct smp_sc *sc, struct smp_seg *sg);
 void smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx);
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 4d6fd9a..09b2497 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -118,7 +118,7 @@ smp_save_segs(struct smp_sc *sc)
  */
 
 void
-smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
+smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
     struct smp_seg *sg)
 {
 	struct smp_object *so;
@@ -128,7 +128,7 @@ smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
 	struct smp_signctx ctx[1];
 
 	ASSERT_SILO_THREAD(sc);
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(sg, SMP_SEG_MAGIC);
 	CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC);
 	assert(sg->flags & SMP_SEG_MUSTLOAD);
@@ -156,11 +156,11 @@ smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
 		oc->flags &= ~OC_F_BUSY;
 		smp_init_oc(oc, sg, no);
 		oc->ban = BAN_RefBan(oc, so->ban, sc->tailban);
-		HSH_Insert(sp, so->hash, oc);
+		HSH_Insert(wrk, so->hash, oc);
 		EXP_Inject(oc, sg->lru, so->ttl);
 		sg->nobj++;
 	}
-	WRK_SumStat(sp->wrk);
+	WRK_SumStat(wrk);
 	sg->flags |= SMP_SEG_LOADED;
 }
 



More information about the varnish-commit mailing list