[master] ee4ae94 fix a potential race
Nils Goroll
nils.goroll at uplex.de
Tue Nov 1 10:14:05 CET 2016
commit ee4ae94cb53a481afdc0222b7a17feec9155df37
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 6ba528e..c497451 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -435,24 +435,26 @@ 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);
THR_SetName("pool_herder");
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