r4205 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed Aug 19 20:53:47 CEST 2009


Author: phk
Date: 2009-08-19 20:53:46 +0200 (Wed, 19 Aug 2009)
New Revision: 4205

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_ban.c
   trunk/varnish-cache/bin/varnishd/cache_ban.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Do the simple part of ban list lurker:  link the objcores off the bans
the reference.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-08-19 02:15:06 UTC (rev 4204)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-08-19 18:53:46 UTC (rev 4205)
@@ -291,6 +291,7 @@
 	unsigned		timer_idx;
 	VTAILQ_ENTRY(objcore)	list;
 	VTAILQ_ENTRY(objcore)	lru_list;
+	VTAILQ_ENTRY(objcore)	ban_list;
 	struct smp_seg		*smp_seg;
 	struct ban		*ban;
 };
@@ -470,7 +471,7 @@
 void BAN_Reload(double t0, unsigned flags, const char *ban);
 struct ban *BAN_TailRef(void);
 void BAN_Compile(void);
-struct ban *BAN_RefBan(double t0, const struct ban *tail);
+struct ban *BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail);
 void BAN_Deref(struct ban **ban);
 
 /* cache_center.c [CNT] */

Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c	2009-08-19 02:15:06 UTC (rev 4204)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c	2009-08-19 18:53:46 UTC (rev 4205)
@@ -81,6 +81,7 @@
 		return (NULL);
 	}
 	VTAILQ_INIT(&b->tests);
+	VTAILQ_INIT(&b->objcore);
 	return (b);
 }
 
@@ -103,6 +104,9 @@
 	struct ban_test *bt;
 
 	CHECK_OBJ_NOTNULL(b, BAN_MAGIC);
+	AZ(b->refcount);
+	assert(VTAILQ_EMPTY(&b->objcore));
+
 	if (b->vsb != NULL)
 		vsb_delete(b->vsb);
 	if (b->test != NULL)
@@ -365,10 +369,12 @@
 {
 
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+	CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC);
 	AZ(o->ban);
 	Lck_Lock(&ban_mtx);
 	o->ban = ban_start;
 	ban_start->refcount++;
+	VTAILQ_INSERT_TAIL(&ban_start->objcore, o->objcore, ban_list);
 	Lck_Unlock(&ban_mtx);
 	o->ban_t = o->ban->t0;
 }
@@ -402,6 +408,7 @@
 	Lck_Lock(&ban_mtx);
 	assert(o->ban->refcount > 0);
 	o->ban->refcount--;
+	VTAILQ_REMOVE(&o->ban->objcore, o->objcore, ban_list);
 	o->ban = NULL;
 
 	/* Attempt to purge last ban entry */
@@ -449,8 +456,11 @@
 
 	Lck_Lock(&ban_mtx);
 	o->ban->refcount--;
-	if (b == o->ban)	/* not banned */
+	VTAILQ_REMOVE(&o->ban->objcore, o->objcore, ban_list);
+	if (b == o->ban) {	/* not banned */
+		VTAILQ_INSERT_TAIL(&b0->objcore, o->objcore, ban_list);
 		b0->refcount++;
+	}
 	VSL_stats->n_purge_obj_test++;
 	VSL_stats->n_purge_re_test += tests;
 	Lck_Unlock(&ban_mtx);
@@ -511,7 +521,7 @@
  */
 
 struct ban *
-BAN_RefBan(double t0, const struct ban *tail)
+BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail)
 {
 	struct ban *b;
 
@@ -525,6 +535,7 @@
 	assert(b->t0 == t0);
 	Lck_Lock(&ban_mtx);
 	b->refcount++;
+	VTAILQ_INSERT_TAIL(&b->objcore, oc, ban_list);
 	Lck_Unlock(&ban_mtx);
 	return (b);
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_ban.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.h	2009-08-19 02:15:06 UTC (rev 4204)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.h	2009-08-19 18:53:46 UTC (rev 4205)
@@ -58,6 +58,7 @@
 #define BAN_F_GONE		(1 << 0)
 #define BAN_F_PENDING		(1 << 1)
 	VTAILQ_HEAD(,ban_test)	tests;
+	VTAILQ_HEAD(,objcore)	objcore;
 	double			t0;
 	struct vsb		*vsb;
 	char			*test;

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2009-08-19 02:15:06 UTC (rev 4204)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2009-08-19 18:53:46 UTC (rev 4205)
@@ -510,10 +510,9 @@
 		sp->objcore->objhead = sp->objhead;
 		sp->objhead = NULL;	/* refcnt follows pointer. */
 		sp->objcore = NULL;	/* refcnt follows pointer. */
+		BAN_NewObj(sp->obj);
 	}
 
-	BAN_NewObj(sp->obj);
-
 	sp->obj->xid = sp->xid;
 	sp->obj->response = sp->err_code;
 	sp->obj->cacheable = sp->wrk->cacheable;

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-08-19 02:15:06 UTC (rev 4204)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-08-19 18:53:46 UTC (rev 4205)
@@ -688,7 +688,8 @@
 	if (r != 0)
 		return;
 
-	BAN_DestroyObj(o);
+	if (oh != NULL)
+		BAN_DestroyObj(o);
 	AZ(o->ban);
 	DSL(0x40, SLT_Debug, 0, "Object %u workspace min free %u",
 	    o->xid, WS_Free(o->ws_o));

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-08-19 02:15:06 UTC (rev 4204)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-08-19 18:53:46 UTC (rev 4205)
@@ -830,7 +830,7 @@
 		oc->flags &= ~OC_F_BUSY;
 		oc->obj = (void*)so;
 		oc->smp_seg = sg;
-		oc->ban = BAN_RefBan(so->ban, sc->tailban);
+		oc->ban = BAN_RefBan(oc, so->ban, sc->tailban);
 		memcpy(sp->wrk->nobjhead->digest, so->hash, SHA256_LEN);
 		(void)HSH_Insert(sp);
 		EXP_Inject(oc, NULL, so->ttl);



More information about the varnish-commit mailing list