[master] 41a719c Urg, forgot the outher loop of the ban-lurker:

Poul-Henning Kamp phk at varnish-cache.org
Mon Feb 20 10:19:59 CET 2012


commit 41a719c98079f44afbf1229be7fb02062dcef5f9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 20 09:19:03 2012 +0000

    Urg, forgot the outher loop of the ban-lurker:
    
    Fix previous change to not madly leak memory.

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index cba6fd1..6e6eafb 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -796,20 +796,17 @@ ban_CheckLast(void)
  */
 
 static int
-ban_lurker_work(struct worker *wrk, unsigned pass)
+ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, unsigned pass)
 {
 	struct ban *b, *b0, *b2;
 	struct objhead *oh;
 	struct objcore *oc, *oc2;
 	struct object *o;
-	struct vsl_log vsl;
 	int i;
 
 	AN(pass & BAN_F_LURK);
 	AZ(pass & ~BAN_F_LURK);
 
-	VSL_Setup(&vsl, NULL, 0);
-
 	/* First route the last ban(s) */
 	do {
 		Lck_Lock(&ban_mtx);
@@ -839,13 +836,13 @@ ban_lurker_work(struct worker *wrk, unsigned pass)
 		b->flags |= pass;
 	}
 	if (cache_param->diag_bitmap & 0x80000)
-		VSLb(&vsl, SLT_Debug, "lurker: %d actionable bans", i);
+		VSLb(vsl, SLT_Debug, "lurker: %d actionable bans", i);
 	if (i == 0)
 		return (0);
 
 	VTAILQ_FOREACH_REVERSE(b, &ban_head, banhead_s, list) {
 		if (cache_param->diag_bitmap & 0x80000)
-			VSLb(&vsl, SLT_Debug, "lurker doing %f %d",
+			VSLb(vsl, SLT_Debug, "lurker doing %f %d",
 			    ban_time(b->spec), b->refcount);
 		while (1) {
 			Lck_Lock(&ban_mtx);
@@ -854,7 +851,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass)
 				break;
 			CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 			if (cache_param->diag_bitmap & 0x80000)
-				VSLb(&vsl, SLT_Debug, "test: %p %u %u",
+				VSLb(vsl, SLT_Debug, "test: %p %u %u",
 				    oc, oc->flags & OC_F_LURK, pass);
 			if ((oc->flags & OC_F_LURK) == pass)
 				break;
@@ -862,7 +859,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass)
 			CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
 			if (Lck_Trylock(&oh->mtx)) {
 				Lck_Unlock(&ban_mtx);
-				VSL_Flush(&vsl, 0);
+				VSL_Flush(vsl, 0);
 				VTIM_sleep(cache_param->ban_lurker_sleep);
 				continue;
 			}
@@ -892,9 +889,9 @@ ban_lurker_work(struct worker *wrk, unsigned pass)
 			 * Get the object and check it against all relevant bans
 			 */
 			o = oc_getobj(&wrk->stats, oc);
-			i = ban_check_object(o, &vsl, NULL);
+			i = ban_check_object(o, vsl, NULL);
 			if (cache_param->diag_bitmap & 0x80000)
-				VSLb(&vsl, SLT_Debug, "lurker got: %p %d",
+				VSLb(vsl, SLT_Debug, "lurker got: %p %d",
 				    oc, i);
 			if (i == -1) {
 				/* Not banned, not moved */
@@ -906,7 +903,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass)
 			}
 			Lck_Unlock(&oh->mtx);
 			if (cache_param->diag_bitmap & 0x80000)
-				VSLb(&vsl, SLT_Debug, "lurker done: %p %u %u",
+				VSLb(vsl, SLT_Debug, "lurker done: %p %u %u",
 				    oc, oc->flags & OC_F_LURK, pass);
 			(void)HSH_Deref(&wrk->stats, NULL, &o);
 			VTIM_sleep(cache_param->ban_lurker_sleep);
@@ -918,7 +915,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass)
 				VSC_C_main->bans_gone++;
 			}
 			if (cache_param->diag_bitmap & 0x80000)
-				VSLb(&vsl, SLT_Debug, "lurker BAN %f now gone",
+				VSLb(vsl, SLT_Debug, "lurker BAN %f now gone",
 				    ban_time(b->spec));
 		}
 		Lck_Unlock(&ban_mtx);
@@ -934,8 +931,11 @@ ban_lurker(struct worker *wrk, void *priv)
 {
 	struct ban *bf;
 	unsigned pass = (1 << LURK_SHIFT);
+	struct vsl_log vsl;
 
 	int i = 0;
+	VSL_Setup(&vsl, NULL, 0);
+
 	(void)priv;
 	while (1) {
 
@@ -953,8 +953,8 @@ ban_lurker(struct worker *wrk, void *priv)
 				VTIM_sleep(1.0);
 		}
 
-		i = ban_lurker_work(wrk, pass);
-		VSL_Flush(wrk->vsl, 0);
+		i = ban_lurker_work(wrk, &vsl, pass);
+		VSL_Flush(&vsl, 0);
 		WRK_SumStat(wrk);
 		if (i) {
 			pass += (1 << LURK_SHIFT);



More information about the varnish-commit mailing list