[master] 3a02001 Make the pass variable a local static of the function which needs it.

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


commit 3a02001bc35914ee4b20b3aed3d4e7a0e9d6800b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Nov 22 12:22:05 2012 +0000

    Make the pass variable a local static of the function which needs it.

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 8ef4962..105a06f 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -844,12 +844,13 @@ ban_CheckLast(void)
  */
 
 static int
-ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, unsigned pass)
+ban_lurker_work(struct worker *wrk, struct vsl_log *vsl)
 {
 	struct ban *b, *b0, *b2;
 	struct objhead *oh;
 	struct objcore *oc, *oc2;
 	struct object *o;
+	static unsigned pass = 1 << LURK_SHIFT;
 	int i;
 
 	AN(pass & BAN_F_LURK);
@@ -984,6 +985,10 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, unsigned pass)
 		if (b == b0)
 			break;
 	}
+	pass += (1 << LURK_SHIFT);
+	pass &= BAN_F_LURK;
+	if (pass == 0)
+		pass += (1 << LURK_SHIFT);
 	return (1);
 }
 
@@ -991,7 +996,6 @@ static void * __match_proto__(bgthread_t)
 ban_lurker(struct worker *wrk, void *priv)
 {
 	struct ban *bf;
-	unsigned pass = (1 << LURK_SHIFT);
 	struct vsl_log vsl;
 
 	int i = 0;
@@ -1018,14 +1022,10 @@ ban_lurker(struct worker *wrk, void *priv)
 				VTIM_sleep(1.0);
 		}
 
-		i = ban_lurker_work(wrk, &vsl, pass);
+		i = ban_lurker_work(wrk, &vsl);
 		VSL_Flush(&vsl, 0);
 		WRK_SumStat(wrk);
 		if (i) {
-			pass += (1 << LURK_SHIFT);
-			pass &= BAN_F_LURK;
-			if (pass == 0)
-				pass += (1 << LURK_SHIFT);
 			VTIM_sleep(cache_param->ban_lurker_sleep);
 		} else {
 			VTIM_sleep(1.0);



More information about the varnish-commit mailing list