r3654 - branches/2.0/varnish-cache/bin/varnishd

tfheen at projects.linpro.no tfheen at projects.linpro.no
Fri Feb 6 12:51:05 CET 2009


Author: tfheen
Date: 2009-02-06 12:51:05 +0100 (Fri, 06 Feb 2009)
New Revision: 3654

Modified:
   branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c
Log:
Merge r3456: Resolve the remove/lookup race the simple way.



Modified: branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c	2009-02-06 11:47:24 UTC (rev 3653)
+++ branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c	2009-02-06 11:51:05 UTC (rev 3654)
@@ -364,6 +364,7 @@
 hcb_lookup(const struct sess *sp, struct objhead *noh)
 {
 	struct objhead *oh;
+	unsigned u;
 	
 	assert(params->hash_sha256);
 	oh =  hcb_insert(&hcb_root, noh, 0);
@@ -371,14 +372,14 @@
 		/* Assert that we didn't muck with the tree without lock */
 		assert(oh != noh);
 		Lck_Lock(&oh->mtx);
-		oh->refcnt++;
+		u = oh->refcnt;
+		if (u)
+			oh->refcnt++;
 		Lck_Unlock(&oh->mtx);
-		VSL_stats->hcb_nolock++;
-		if (0) {
-			fprintf(stderr, "%s %d\n", __func__, __LINE__);
-			dump(&hcb_root, stderr);
+		if (u) {
+			VSL_stats->hcb_nolock++;
+			return (oh);
 		}
-		return (oh);
 	}
 
 	/*



More information about the varnish-commit mailing list