[PATCH 03/15] Fix bug in smp_baninfo causing duplicate ban entries.

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


When generalizing the ban event reporting to the stevedores, where the
event was reported first for each stevedore, and then for each silo on
the global silos list. Fix this by adding a flag for when the silo is
fully opened and ready for accepting ban events, and don't recurse on
the global silos list.
---
 bin/varnishd/storage/storage_persistent.c |   16 +++++++++++-----
 bin/varnishd/storage/storage_persistent.h |    5 +++--
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 24a4d08..3a6ade5 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -98,13 +98,16 @@ smp_baninfo(struct stevedore *stv, enum baninfo event,
 {
 	struct smp_sc *sc;
 
-	(void)stv;
+	CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
+
+	if (!(sc->flags & SMP_SC_OPENED))
+		/* Ignore ban events until we have been opened */
+		return;
+
 	switch (event) {
 	case BI_NEW:
-		VTAILQ_FOREACH(sc, &silos, list) {
-			smp_appendban(sc, &sc->ban1, len, ban);
-			smp_appendban(sc, &sc->ban2, len, ban);
-		}
+		smp_appendban(sc, &sc->ban1, len, ban);
+		smp_appendban(sc, &sc->ban2, len, ban);
 		break;
 	default:
 		/* Ignored */
@@ -360,6 +363,9 @@ smp_open(const struct stevedore *st)
 	if (smp_open_segs(sc, &sc->seg1))
 		AZ(smp_open_segs(sc, &sc->seg2));
 
+	/* We are now open for business */
+	sc->flags |= SMP_SC_OPENED;
+
 	/*
 	 * Grap a reference to the tail of the ban list, until the thread
 	 * has loaded all objects, so we can be sure that all of our
diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h
index cb2efb3..6609e78 100644
--- a/bin/varnishd/storage/storage_persistent.h
+++ b/bin/varnishd/storage/storage_persistent.h
@@ -106,8 +106,9 @@ struct smp_sc {
 
 	pthread_t		bgthread;
 	unsigned		flags;
-#define SMP_SC_LOADED		(1 << 0)
-#define SMP_SC_STOP		(1 << 1)
+#define SMP_SC_OPENED		(1 << 0)
+#define SMP_SC_LOADED		(1 << 1)
+#define SMP_SC_STOP		(1 << 2)
 
 	const struct stevedore	*stevedore;
 	int			fd;
-- 
1.7.9.5




More information about the varnish-dev mailing list