[master] a6b9848 Eliminated duplicated code for trimming the tail of the banlist.

Poul-Henning Kamp phk at varnish-cache.org
Thu Nov 22 13:57:30 CET 2012


commit a6b98489174224c65357728036ca9f963d47ac86
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Nov 22 12:56:54 2012 +0000

    Eliminated duplicated code for trimming the tail of the banlist.
    
    Original patch by:	martin

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 105a06f..688842b 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -846,7 +846,7 @@ ban_CheckLast(void)
 static int
 ban_lurker_work(struct worker *wrk, struct vsl_log *vsl)
 {
-	struct ban *b, *b0, *b2;
+	struct ban *b, *b0;
 	struct objhead *oh;
 	struct objcore *oc, *oc2;
 	struct object *o;
@@ -856,18 +856,6 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl)
 	AN(pass & BAN_F_LURK);
 	AZ(pass & ~BAN_F_LURK);
 
-	/* First route the last ban(s) */
-	do {
-		Lck_Lock(&ban_mtx);
-		b2 = ban_CheckLast();
-		if (b2 != NULL)
-			/* Notify stevedores */
-			STV_BanInfo(BI_DROP, b2->spec, ban_len(b2->spec));
-		Lck_Unlock(&ban_mtx);
-		if (b2 != NULL)
-			BAN_Free(b2);
-	} while (b2 != NULL);
-
 	/*
 	 * Find out if we have any bans we can do something about
 	 * If we find any, tag them with our pass number.
@@ -1004,7 +992,7 @@ ban_lurker(struct worker *wrk, void *priv)
 	(void)priv;
 	while (1) {
 
-		while (cache_param->ban_lurker_sleep == 0.0) {
+		do {
 			/*
 			 * Ban-lurker is disabled:
 			 * Clean the last ban, if possible, and sleep
@@ -1018,18 +1006,19 @@ ban_lurker(struct worker *wrk, void *priv)
 			Lck_Unlock(&ban_mtx);
 			if (bf != NULL)
 				BAN_Free(bf);
-			else
-				VTIM_sleep(1.0);
-		}
-
-		i = ban_lurker_work(wrk, &vsl);
-		VSL_Flush(&vsl, 0);
-		WRK_SumStat(wrk);
-		if (i) {
-			VTIM_sleep(cache_param->ban_lurker_sleep);
-		} else {
-			VTIM_sleep(1.0);
+		} while (bf != NULL);
+
+		if (cache_param->ban_lurker_sleep != 0.0) {
+			do {
+				i = ban_lurker_work(wrk, &vsl);
+				VSL_Flush(&vsl, 0);
+				WRK_SumStat(wrk);
+				if (i)
+					VTIM_sleep(
+					    cache_param->ban_lurker_sleep);
+			} while (i);
 		}
+		VTIM_sleep(0.609);	// Random, non-magic
 	}
 	NEEDLESS_RETURN(NULL);
 }



More information about the varnish-commit mailing list