This is now only done in the main ban_lurker thread loop.
---
 bin/varnishd/cache/cache_ban.c |   50 +++++++++++++++-------------------------
 1 file changed, 18 insertions(+), 32 deletions(-)

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index bf671bc..47a8518 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -835,7 +835,7 @@ ban_CheckLast(void)
 static int
 ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, unsigned pass)
 {
-       struct ban *b, *b0, *b2;
+       struct ban *b, *b0;
        struct objhead *oh;
        struct objcore *oc, *oc2;
        struct object *o;
@@ -844,18 +844,6 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, 
unsigned pass)
        AN(pass & BAN_F_LURK);
        AZ(pass & ~BAN_F_LURK);
 
-       /* First route the last ban(s) */
-       do {
-               Lck_Lock(&ban_mtx);
-               b2 = ban_CheckLast();
-               if (b2 != NULL)
-                       /* Notify stevedores */
-                       STV_BanInfo(BI_DROP, b2->spec, ban_len(b2->spec));
-               Lck_Unlock(&ban_mtx);
-               if (b2 != NULL)
-                       BAN_Free(b2);
-       } while (b2 != NULL);
-
        /*
         * Find out if we have any bans we can do something about
         * If we find any, tag them with our pass number.
@@ -982,18 +970,16 @@ ban_lurker(struct worker *wrk, void *priv)
        struct ban *bf;
        unsigned pass = (1 << LURK_SHIFT);
        struct vsl_log vsl;
+       double ban_sleep;
 
-       int i = 0;
        VSL_Setup(&vsl, NULL, 0);
 
        (void)priv;
        while (1) {
+               ban_sleep = 1.0;
 
-               while (cache_param->ban_lurker_sleep == 0.0) {
-                       /*
-                        * Ban-lurker is disabled:
-                        * Clean the last ban, if possible, and sleep
-                        */
+               /* Clear any gone last bans */
+               do {
                        Lck_Lock(&ban_mtx);
                        bf = ban_CheckLast();
                        if (bf != NULL)
@@ -1003,22 +989,22 @@ ban_lurker(struct worker *wrk, void *priv)
                        Lck_Unlock(&ban_mtx);
                        if (bf != NULL)
                                BAN_Free(bf);
-                       else
-                               VTIM_sleep(1.0);
-               }
+               } while (bf != NULL);
 
-               i = ban_lurker_work(wrk, &vsl, pass);
-               VSL_Flush(&vsl, 0);
-               WRK_SumStat(wrk);
-               if (i) {
-                       pass += (1 << LURK_SHIFT);
-                       pass &= BAN_F_LURK;
-                       if (pass == 0)
+               if (cache_param->ban_lurker_sleep != 0.0) {
+                       /* Ban lurker enabled */
+                       if (ban_lurker_work(wrk, &vsl, pass)) {
                                pass += (1 << LURK_SHIFT);
-                       VTIM_sleep(cache_param->ban_lurker_sleep);
-               } else {
-                       VTIM_sleep(1.0);
+                               pass &= BAN_F_LURK;
+                               if (pass == 0)
+                                       pass += (1 << LURK_SHIFT);
+                               ban_sleep = cache_param->ban_lurker_sleep;
+                       }
+                       VSL_Flush(&vsl, 0);
+                       WRK_SumStat(wrk);
                }
+
+               VTIM_sleep(ban_sleep);
        }
        NEEDLESS_RETURN(NULL);
 }
-- 
1.7.9.5


_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to