[3.0] 9528984 Avoid taking the saintmode lock if the list empty.

Tollef Fog Heen tfheen at varnish-cache.org
Thu May 24 14:51:10 CEST 2012


commit 95289844b65349f15e9449cafc907ca7c2057451
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 27 08:47:12 2012 +0000

    Avoid taking the saintmode lock if the list empty.
    
    Submitted by:	DocWilco

diff --git a/bin/varnishd/cache_backend.c b/bin/varnishd/cache_backend.c
index 756d659..7e36bda 100644
--- a/bin/varnishd/cache_backend.c
+++ b/bin/varnishd/cache_backend.c
@@ -268,16 +268,15 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
 	/* VRT/VCC sets threshold to UINT_MAX to mark that it's not
 	 * specified by VCL (thus use param).
 	 */
-	if (vs->vrt->saintmode_threshold == UINT_MAX)
+	threshold = vs->vrt->saintmode_threshold;
+	if (threshold == UINT_MAX)
 		threshold = params->saintmode_threshold;
-	else
-		threshold = vs->vrt->saintmode_threshold;
 
 	if (backend->admin_health == ah_healthy)
 		threshold = UINT_MAX;
 
-	/* Saintmode is disabled */
-	if (threshold == 0)
+	/* Saintmode is disabled, or list is empty */
+	if (threshold == 0 || VTAILQ_EMPTY(&backend->troublelist))
 		return (1);
 
 	if (sp->objcore == NULL)



More information about the varnish-commit mailing list