r5561 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Sat Nov 20 23:23:56 CET 2010


Author: phk
Date: 2010-11-20 23:23:56 +0100 (Sat, 20 Nov 2010)
New Revision: 5561

Modified:
   trunk/varnish-cache/bin/varnishd/stevedore.c
   trunk/varnish-cache/bin/varnishd/stevedore.h
   trunk/varnish-cache/bin/varnishd/storage_file.c
   trunk/varnish-cache/bin/varnishd/storage_malloc.c
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Eliminate the objcore argument from plain stv->alloc(), -spersistent
does not require it any more.




Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c	2010-11-20 21:59:43 UTC (rev 5560)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c	2010-11-20 22:23:56 UTC (rev 5561)
@@ -100,7 +100,7 @@
 /*********************************************************************/
 
 static struct storage *
-stv_alloc(const struct sess *sp, size_t size, struct objcore *oc)
+stv_alloc(const struct sess *sp, size_t size)
 {
 	struct storage *st;
 	struct stevedore *stv = NULL;
@@ -126,7 +126,7 @@
 
 		/* try to allocate from it */
 		AN(stv->alloc);
-		st = stv->alloc(stv, size, oc);
+		st = stv->alloc(stv, size);
 		if (st != NULL)
 			break;
 
@@ -224,7 +224,7 @@
 	struct storage *st;
 
 	CHECK_OBJ_NOTNULL(soc, STV_OBJ_SECRETES_MAGIC);
-	st = stv->alloc(stv, ltot, sp->objcore);
+	st = stv->alloc(stv, ltot);
 	XXXAN(st);
 	xxxassert(st->space >= ltot);
 	ltot = st->len = st->space;
@@ -321,7 +321,7 @@
 STV_alloc(const struct sess *sp, size_t size)
 {
 
-	return (stv_alloc(sp, size, NULL));
+	return (stv_alloc(sp, size));
 }
 
 void

Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h	2010-11-20 21:59:43 UTC (rev 5560)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h	2010-11-20 22:23:56 UTC (rev 5561)
@@ -38,8 +38,7 @@
 
 typedef void storage_init_f(struct stevedore *, int ac, char * const *av);
 typedef void storage_open_f(const struct stevedore *);
-typedef struct storage *storage_alloc_f(struct stevedore *, size_t size,
-    struct objcore *);
+typedef struct storage *storage_alloc_f(struct stevedore *, size_t size);
 typedef void storage_trim_f(struct storage *, size_t size);
 typedef void storage_free_f(struct storage *);
 typedef void storage_object_f(const struct sess *sp);

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c	2010-11-20 21:59:43 UTC (rev 5560)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c	2010-11-20 22:23:56 UTC (rev 5561)
@@ -461,12 +461,11 @@
 /*--------------------------------------------------------------------*/
 
 static struct storage *
-smf_alloc(struct stevedore *st, size_t size, struct objcore *oc)
+smf_alloc(struct stevedore *st, size_t size)
 {
 	struct smf *smf;
 	struct smf_sc *sc;
 
-	(void)oc;
 	CAST_OBJ_NOTNULL(sc, st->priv, SMF_SC_MAGIC);
 	assert(size > 0);
 	size += (sc->pagesize - 1);

Modified: trunk/varnish-cache/bin/varnishd/storage_malloc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_malloc.c	2010-11-20 21:59:43 UTC (rev 5560)
+++ trunk/varnish-cache/bin/varnishd/storage_malloc.c	2010-11-20 22:23:56 UTC (rev 5561)
@@ -59,13 +59,12 @@
 };
 
 static struct storage *
-sma_alloc(struct stevedore *st, size_t size, struct objcore *oc)
+sma_alloc(struct stevedore *st, size_t size)
 {
 	struct sma_sc *sma_sc;
 	struct sma *sma;
 
 	CAST_OBJ_NOTNULL(sma_sc, st->priv, SMA_SC_MAGIC);
-	(void)oc;
 	Lck_Lock(&sma_sc->sma_mtx);
 	sma_sc->stats->nreq++;
 	if (sma_sc->stats->nbytes + size > sma_sc->sma_max)

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2010-11-20 21:59:43 UTC (rev 5560)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2010-11-20 22:23:56 UTC (rev 5561)
@@ -69,9 +69,6 @@
 
 #define OC_F_NEEDFIXUP OC_F_PRIV
 
-static struct storage *smp_alloc(struct stevedore *st, size_t size,
-    struct objcore *oc);
-
 /*
  * Context for a signature.
  *
@@ -1289,70 +1286,11 @@
 }
 
 /*--------------------------------------------------------------------
- * Allocate an object
- */
-
-static struct object *
-smp_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot,
-    struct stv_objsecrets *soc)
-{
-	struct object *o;
-	struct storage *st;
-
-	st = smp_alloc(stv, ltot, sp->objcore);
-	XXXAN(st);
-	xxxassert(st->space >= ltot);
-	ltot = st->len = st->space;
-	o = STV_MkObject(sp, st->ptr, ltot, soc);
-	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	o->objstore = st;
-	return (o);
-}
-
-
-/*--------------------------------------------------------------------
- * Designate object
- */
-
-static void
-smp_object(const struct sess *sp)
-{
-	struct smp_sc	*sc;
-	struct smp_seg *sg;
-	struct smp_object *so;
-
-
-	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->obj->objstore, STORAGE_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->obj->objstore->stevedore, STEVEDORE_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->obj->objcore, OBJCORE_MAGIC);
-	CAST_OBJ_NOTNULL(sg, sp->obj->objcore->priv2, SMP_SEG_MAGIC);
-	CAST_OBJ_NOTNULL(sc, sp->obj->objstore->priv, SMP_SC_MAGIC);
-
-	sp->obj->objcore->flags |= OC_F_LRUDONTMOVE;
-
-	Lck_Lock(&sc->mtx);
-	assert(sg->nalloc2 < sg->nalloc1);
-
-	sp->obj->smp_index = sg->nalloc2++;
-	so = &sg->objs[sp->obj->smp_index];
-	sg->nfixed++;
-	sg->nobj++;
-	assert(sizeof so->hash == DIGEST_LEN);
-	memcpy(so->hash, sp->obj->objcore->objhead->digest, DIGEST_LEN);
-	so->ttl = sp->obj->ttl;
-	so->ptr = sp->obj;
-	so->ban = sp->obj->ban_t;
-
-	Lck_Unlock(&sc->mtx);
-}
-
-/*--------------------------------------------------------------------
  * Allocate a bite
  */
 
 static struct storage *
-smp_alloc(struct stevedore *st, size_t size, struct objcore *oc)
+smp_allocx(struct stevedore *st, size_t size, struct objcore *oc)
 {
 	struct smp_sc *sc;
 	struct storage *ss;
@@ -1453,7 +1391,78 @@
 	return (ss);
 }
 
+
+/*--------------------------------------------------------------------
+ * Allocate an object
+ */
+
+static struct object *
+smp_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot,
+    struct stv_objsecrets *soc)
+{
+	struct object *o;
+	struct storage *st;
+
+	st = smp_allocx(stv, ltot, sp->objcore);
+	XXXAN(st);
+	xxxassert(st->space >= ltot);
+	ltot = st->len = st->space;
+	o = STV_MkObject(sp, st->ptr, ltot, soc);
+	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+	o->objstore = st;
+	return (o);
+}
+
+
+/*--------------------------------------------------------------------
+ * Designate object
+ */
+
 static void
+smp_object(const struct sess *sp)
+{
+	struct smp_sc	*sc;
+	struct smp_seg *sg;
+	struct smp_object *so;
+
+
+	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+	CHECK_OBJ_NOTNULL(sp->obj->objstore, STORAGE_MAGIC);
+	CHECK_OBJ_NOTNULL(sp->obj->objstore->stevedore, STEVEDORE_MAGIC);
+	CHECK_OBJ_NOTNULL(sp->obj->objcore, OBJCORE_MAGIC);
+	CAST_OBJ_NOTNULL(sg, sp->obj->objcore->priv2, SMP_SEG_MAGIC);
+	CAST_OBJ_NOTNULL(sc, sp->obj->objstore->priv, SMP_SC_MAGIC);
+
+	sp->obj->objcore->flags |= OC_F_LRUDONTMOVE;
+
+	Lck_Lock(&sc->mtx);
+	assert(sg->nalloc2 < sg->nalloc1);
+
+	sp->obj->smp_index = sg->nalloc2++;
+	so = &sg->objs[sp->obj->smp_index];
+	sg->nfixed++;
+	sg->nobj++;
+	assert(sizeof so->hash == DIGEST_LEN);
+	memcpy(so->hash, sp->obj->objcore->objhead->digest, DIGEST_LEN);
+	so->ttl = sp->obj->ttl;
+	so->ptr = sp->obj;
+	so->ban = sp->obj->ban_t;
+
+	Lck_Unlock(&sc->mtx);
+}
+
+/*--------------------------------------------------------------------
+ * Allocate a bite
+ */
+
+static struct storage *
+smp_alloc(struct stevedore *st, size_t size)
+{
+
+	return (smp_allocx(st, size, NULL));
+}
+
+static void
 smp_trim(struct storage *ss, size_t size)
 {
 	struct smp_sc *sc;




More information about the varnish-commit mailing list