From: Yann Collet Date: Fri, 22 Jun 2018 01:04:58 +0000 (-0700) Subject: add a cond_broadcast after resize X-Git-Tag: v1.3.5~3^2~8^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=243cd9d8bbc4cc907b661512c907dc85203a8d87;p=thirdparty%2Fzstd.git add a cond_broadcast after resize to make sure all threads (notably newly available threads) get awaken to immediately process potential items in the queue. --- diff --git a/lib/common/pool.c b/lib/common/pool.c index bd31f032f..41a216f16 100644 --- a/lib/common/pool.c +++ b/lib/common/pool.c @@ -225,13 +225,16 @@ static POOL_ctx* POOL_resize_internal(POOL_ctx* ctx, size_t numThreads) * note : starting context is considered consumed. */ POOL_ctx* POOL_resize(POOL_ctx* ctx, size_t numThreads) { - POOL_ctx* newCtx; if (ctx==NULL) return NULL; ZSTD_pthread_mutex_lock(&ctx->queueMutex); - newCtx = POOL_resize_internal(ctx, numThreads); + { POOL_ctx* const newCtx = POOL_resize_internal(ctx, numThreads); + if (newCtx!=ctx) { + POOL_free(ctx); + return newCtx; + } } + ZSTD_pthread_cond_broadcast(&ctx->queuePopCond); ZSTD_pthread_mutex_unlock(&ctx->queueMutex); - if (newCtx!=ctx) POOL_free(ctx); - return newCtx; + return ctx; } /**