[master] 2bd5d2adf Make threads_limited counter accurate

Nils Goroll nils.goroll at uplex.de
Sun Feb 21 11:59:08 UTC 2021

commit 2bd5d2adfc407216ebaa653fae882d3c8d47f5e1
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Sun Feb 21 12:41:49 2021 +0100

    Make threads_limited counter accurate
    In pool_herder(), we do as much work as possible outside the pool
    mutex. In particular, we check if we need to breed more threads, then
    we do more checks, and finally we aquire the lock and either go sleep
    or increase the threads_limited counter if, at that point, lqueue is
    Yet it could have increased since we last checked, and there is
    nothing wrong with that, we will breed a new thread in the next
    iteration of the loop.
    Increase threads_limited only if we would not bread a new thread right
    Fixes #3531

diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 9b6933cae..bd89940b7 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -681,7 +681,7 @@ pool_herder(void *priv)
 				delay = 0.5;
 			(void)Lck_CondWait(&pp->herder_cond, &pp->mtx,
 				VTIM_real() + delay);
-		} else
+		} else if (pp->nthr >= cache_param->wthread_max)
 			/* XXX: unsafe counters */

More information about the varnish-commit mailing list