]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
add a cond_broadcast after resize
authorYann Collet <cyan@fb.com>
Fri, 22 Jun 2018 01:04:58 +0000 (18:04 -0700)
committerYann Collet <cyan@fb.com>
Fri, 22 Jun 2018 01:04:58 +0000 (18:04 -0700)
to make sure all threads (notably newly available threads)
get awaken to immediately process potential items in the queue.

lib/common/pool.c

index bd31f032ff3323f123404fa7dde2562bba988594..41a216f16140d8e4b6376dbeed754a627cb2a02d 100644 (file)
@@ -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;
 }
 
 /**