[master] 27b951bbc count all bans towards ban_cutoff

Nils Goroll nils.goroll at uplex.de
Mon Dec 7 13:42:07 UTC 2020


commit 27b951bbc4a724903b4d46a7516e915ef05b6407
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Dec 7 14:14:04 2020 +0100

    count all bans towards ban_cutoff
    
    ... also (C)ompleted bans.
    
    The previous code made a lot of sense in light of the performance issue
    due to too many bans, but would not work to prune a long ban list due to
    (R)equest bans at the tail, as in this example:
    
    Present bans:
    1607346873.538879 354304 C
    1607346873.532313     0 C
    ... lots of (C)ompleted bans
    1607083561.980118     0 -  req.http.Host ~ foo
    1607083561.972629    15 C
    
    The documentation does not mention the previous behavior (that only
    "active" bans are being counted), so this changes aligns code to
    documentation.

diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c
index 480d5adfc..25bfa604c 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -371,7 +371,7 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl)
 	d = VTIM_real() - cache_param->ban_lurker_age;
 	bd = NULL;
 	VTAILQ_INIT(&obans);
-	for (; b != NULL; b = VTAILQ_NEXT(b, list)) {
+	for (; b != NULL; b = VTAILQ_NEXT(b, list), count++) {
 		if (bd != NULL)
 			ban_lurker_test_ban(wrk, vsl, b, &obans, bd,
 			    count > cutoff ? 1 : 0);
@@ -383,7 +383,6 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl)
 				bd = VTAILQ_NEXT(b, list);
 			continue;
 		}
-		count++;
 		n = ban_time(b->spec) - d;
 		if (n < 0) {
 			VTAILQ_INSERT_TAIL(&obans, b, l_list);


More information about the varnish-commit mailing list