[4.1] 674cd52 fix a potential race
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Tue Nov 22 14:31:04 CET 2016
commit 674cd52130457657db62b7c5c810477a74ca3885
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Oct 27 13:00:20 2016 +0200
fix a potential race
The nthr => wthread_min assertion could trigger if
wthread_min was changed after the first comparison.
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 43c0384..3625365 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -435,22 +435,24 @@ pool_herder(void *priv)
struct pool_task *pt;
double t_idle;
struct worker *wrk;
- int delay;
+ int delay, wthread_min;
CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC);
while (1) {
+ wthread_min = cache_param->wthread_min;
+
/* Make more threads if needed and allowed */
- if (pp->nthr < cache_param->wthread_min ||
+ if (pp->nthr < wthread_min ||
(pp->dry && pp->nthr < cache_param->wthread_max)) {
pool_breed(pp);
continue;
}
delay = cache_param->wthread_timeout;
- assert(pp->nthr >= cache_param->wthread_min);
+ assert(pp->nthr >= wthread_min);
- if (pp->nthr > cache_param->wthread_min) {
+ if (pp->nthr > wthread_min) {
t_idle = VTIM_real() - cache_param->wthread_timeout;
More information about the varnish-commit
mailing list