[PATCH 14/15] Keep track of how many bans we have in the silo ban lists, and how many of these have since been dropped or marked gone.

Martin Blix Grydeland martin at varnish-software.com
Wed Nov 7 12:32:17 CET 2012


---
 bin/varnishd/storage/storage_persistent.c |   11 +++++++++++
 bin/varnishd/storage/storage_persistent.h |    7 +++++++
 2 files changed, 18 insertions(+)

diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index bfa5e0c..86b94f8 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -110,6 +110,13 @@ smp_baninfo(struct stevedore *stv, enum baninfo event, const struct ban *ban)
 		BAN_Spec(ban, &spec, &len);
 		smp_appendban(sc, &sc->ban1, len, spec);
 		smp_appendban(sc, &sc->ban2, len, spec);
+		sc->n_ban++;
+		break;
+	case BI_DROP:
+		sc->n_ban_dropped++;
+		break;
+	case BI_GONE:
+		sc->n_ban_gone++;
 		break;
 	default:
 		/* Ignored */
@@ -132,6 +139,7 @@ smp_recompile_bans(struct smp_sc *sc, const struct ban *tail)
 	/* Write the list to ban1 */
 	smp_reset_signspace(&sc->ban1);
 	ptr = ptr2 = SIGNSPACE_FRONT(&sc->ban1);
+	sc->n_ban = sc->n_ban_dropped = sc->n_ban_gone = 0;
 	for (b = tail; b != NULL; b = BAN_Prev(b)) {
 		BAN_Spec(b, &spec, &len);
 		assert(SIGNSPACE_FREE(&sc->ban1) >= (ptr - ptr2) + 4 + 4 + len);
@@ -141,6 +149,7 @@ smp_recompile_bans(struct smp_sc *sc, const struct ban *tail)
 		ptr += 4;
 		memcpy(ptr, spec, len);
 		ptr += len;
+		sc->n_ban++;
 	}
 	smp_append_signspace(&sc->ban1, ptr - ptr2);
 	smp_sync_sign(&sc->ban1.ctx);
@@ -184,6 +193,7 @@ smp_open_bans(struct smp_sc *sc, struct smp_signspace *spc)
 	ptr = SIGNSPACE_DATA(spc);
 	pe = SIGNSPACE_FRONT(spc);
 
+	sc->n_ban = sc->n_ban_dropped = sc->n_ban_gone = 0;
 	while (ptr < pe) {
 		if (memcmp(ptr, "BAN", 4)) {
 			retval = 1001;
@@ -200,6 +210,7 @@ smp_open_bans(struct smp_sc *sc, struct smp_signspace *spc)
 		}
 
 		BAN_Reload(ptr, length);
+		sc->n_ban++;
 
 		ptr += length;
 	}
diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h
index 6609e78..8a3f145 100644
--- a/bin/varnishd/storage/storage_persistent.h
+++ b/bin/varnishd/storage/storage_persistent.h
@@ -139,6 +139,13 @@ struct smp_sc {
 	struct smp_signspace	seg1;
 	struct smp_signspace	seg2;
 
+	/* Counters to keep track of how many bans we have in the
+	 * lists, and how many of these that has since been dropped or
+	 * marked gone */
+	unsigned		n_ban;
+	unsigned		n_ban_dropped;
+	unsigned		n_ban_gone;
+
 	struct ban		*tailban;
 
 	struct lock		mtx;
-- 
1.7.9.5




More information about the varnish-dev mailing list