r5432 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Mon Oct 18 17:23:38 CEST 2010


Author: phk
Date: 2010-10-18 17:23:38 +0200 (Mon, 18 Oct 2010)
New Revision: 5432

Modified:
   trunk/varnish-cache/bin/varnishd/cache_hash.c
Log:
There is a potential lock-order inversion between a worker thread
and the ban-lurker and there is nothing we can do about it:  They
come from opposite ends of the world.

Resolve this by using a TryLock in the ban-lurker and abandon the
attempt if we fail to get the lock.

Fixes:	#796


Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2010-10-16 17:24:30 UTC (rev 5431)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2010-10-18 15:23:38 UTC (rev 5432)
@@ -661,7 +661,10 @@
 	CHECK_OBJ_NOTNULL(oc1, OBJCORE_MAGIC);
 	oh = oc1->objhead;
 	CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
-	Lck_Lock(&oh->mtx);
+	if (Lck_Trylock(&oh->mtx)) {
+		*oc = NULL;
+		return;
+	}
 	VTAILQ_FOREACH(oc2, &oh->objcs, list)
 		if (oc1 == oc2)
 			break;




More information about the varnish-commit mailing list