fixed: bug when counting nb of active threads

when queueSize > 1

also : added a test in testpool.c
       verifying resizing is effective.
This commit is contained in:
Yann Collet
2018-06-20 18:28:49 -07:00
parent 6b48eb12c0
commit 6de249c1c6
2 changed files with 115 additions and 24 deletions
+5 -4
View File
@@ -91,12 +91,13 @@ static void* POOL_thread(void* opaque) {
job.function(job.opaque);
/* If the intended queue size was 0, signal after finishing job */
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
ctx->numThreadsBusy--;
if (ctx->queueSize == 1) {
ZSTD_pthread_mutex_lock(&ctx->queueMutex);
ctx->numThreadsBusy--;
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
ZSTD_pthread_cond_signal(&ctx->queuePushCond);
} }
}
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
}
} /* for (;;) */
assert(0); /* Unreachable */
}