[master] 57240f5 Decontaminate STV_alloc() to not need session

Poul-Henning Kamp phk at varnish-cache.org
Mon Oct 24 14:36:57 CEST 2011


commit 57240f5a3e76cbd968518e0325de97bf09d293ea
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 24 12:36:22 2011 +0000

    Decontaminate STV_alloc() to not need session

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 71cc776..a8dff7b 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -950,7 +950,8 @@ int RFC2616_Do_Cond(const struct sess *sp);
 /* stevedore.c */
 struct object *STV_NewObject(struct sess *sp, const char *hint, unsigned len,
     struct exp *, uint16_t nhttp);
-struct storage *STV_alloc(const struct sess *sp, size_t size);
+struct storage *STV_alloc(struct worker *w, const struct object *obj,
+    size_t size);
 void STV_trim(struct storage *st, size_t size);
 void STV_free(struct storage *st);
 void STV_open(void);
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index f69e900..5d8f8dc 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -368,7 +368,7 @@ vfp_esi_end(struct sess *sp)
 		l = VSB_len(vsb);
 		assert(l > 0);
 		/* XXX: This is a huge waste of storage... */
-		sp->obj->esidata = STV_alloc(sp, l);
+		sp->obj->esidata = STV_alloc(sp->wrk, sp->obj, l);
 		XXXAN(sp->obj->esidata);
 		memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l);
 		sp->obj->esidata->len = l;
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index eae583d..ccc2ec3 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -159,7 +159,7 @@ FetchStorage(const struct sess *sp, ssize_t sz)
 		l = sz;
 	if (l == 0)
 		l = params->fetch_chunksize * 1024LL;
-	st = STV_alloc(sp, l);
+	st = STV_alloc(sp->wrk, sp->obj, l);
 	if (st == NULL) {
 		errno = ENOMEM;
 		return (NULL);
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index bd42e54..93e2bf8 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -154,7 +154,7 @@ stv_pick_stevedore(const struct sess *sp, const char **hint)
 /*-------------------------------------------------------------------*/
 
 static struct storage *
-stv_alloc(const struct sess *sp, size_t size)
+stv_alloc(struct worker *w, const struct object *obj, size_t size)
 {
 	struct storage *st;
 	struct stevedore *stv;
@@ -164,8 +164,9 @@ stv_alloc(const struct sess *sp, size_t size)
 	 * Always use the stevedore which allocated the object in order to
 	 * keep an object inside the same stevedore.
 	 */
-	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
-	stv = sp->obj->objstore->stevedore;
+	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+	stv = obj->objstore->stevedore;
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
 
 	if (size > (size_t)(params->fetch_maxchunksize) << 10)
@@ -184,7 +185,7 @@ stv_alloc(const struct sess *sp, size_t size)
 		}
 
 		/* no luck; try to free some space and keep trying */
-		if (EXP_NukeOne(sp->wrk, stv->lru) == -1)
+		if (EXP_NukeOne(w, stv->lru) == -1)
 			break;
 
 		/* Enough is enough: try another if we have one */
@@ -370,10 +371,10 @@ STV_Freestore(struct object *o)
 /*-------------------------------------------------------------------*/
 
 struct storage *
-STV_alloc(const struct sess *sp, size_t size)
+STV_alloc(struct worker *w, const struct object *obj, size_t size)
 {
 
-	return (stv_alloc(sp, size));
+	return (stv_alloc(w, obj, size));
 }
 
 void



More information about the varnish-commit mailing list