r4548 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed Feb 10 13:44:43 CET 2010


Author: phk
Date: 2010-02-10 13:44:42 +0100 (Wed, 10 Feb 2010)
New Revision: 4548

Modified:
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/hash_slinger.h
Log:
Be much more paranoid about objhead refcounts



Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2010-02-10 12:38:34 UTC (rev 4547)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2010-02-10 12:44:42 UTC (rev 4548)
@@ -290,6 +290,7 @@
 	if (oh == w->nobjhead)
 		w->nobjhead = NULL;
 	Lck_Lock(&oh->mtx);
+	assert(oh->refcnt > 0);
 
 	/* Insert (precreated) objcore in objecthead */
 	oc = w->nobjcore;
@@ -337,17 +338,16 @@
 		CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);
 		oh = sp->objhead;
 		sp->objhead = NULL;
-		CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
-		Lck_Lock(&oh->mtx);
 	} else {
 		AN(w->nobjhead);
 		oh = hash->lookup(sp, w->nobjhead);
-		CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
 		if (oh == w->nobjhead)
 			w->nobjhead = NULL;
-		Lck_Lock(&oh->mtx);
 	}
 
+	CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
+	Lck_Lock(&oh->mtx);
+	assert(oh->refcnt > 0);
 	busy_oc = NULL;
 	grace_oc = NULL;
 	VTAILQ_FOREACH(oc, &oh->objcs, list) {
@@ -532,6 +532,7 @@
 		    "Object %u workspace free %u", o->xid, WS_Free(o->ws_o));
 
 	Lck_Lock(&oh->mtx);
+	assert(oh->refcnt > 0);
 	o->objcore->flags &= ~OC_F_BUSY;
 	hsh_rush(oh);
 	AN(o->ban);

Modified: trunk/varnish-cache/bin/varnishd/hash_slinger.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_slinger.h	2010-02-10 12:38:34 UTC (rev 4547)
+++ trunk/varnish-cache/bin/varnishd/hash_slinger.h	2010-02-10 12:44:42 UTC (rev 4548)
@@ -72,7 +72,7 @@
 #define OBJHEAD_MAGIC		0x1b96615d
 
 	struct lock		mtx;
-	unsigned		refcnt;
+	int			refcnt;
 	VTAILQ_HEAD(,objcore)	objcs;
 	unsigned char		digest[DIGEST_LEN];
 	union {



More information about the varnish-commit mailing list