Commit ee4ae94c authored by Nils Goroll's avatar Nils Goroll

fix a potential race

The nthr => wthread_min assertion could trigger if
wthread_min was changed after the first comparison.
parent 5e5b4d59
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment