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 1efa24b..e2cf429 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -88,13 +88,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 */
@@ -331,6 +334,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.10.4


_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to