From 754ae5cc0bc47e96bc30163c007295859dc04c29 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 28 Sep 2017 20:44:22 -0700 Subject: [PATCH] removed ZSTDMT_waitForAllJobsCompleted() from ZSTDMT_freeCCtx() as per @terrelln comment --- lib/compress/zstdmt_compress.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index bc7d1e54..bfa1c42d 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -514,13 +514,10 @@ static void ZSTDMT_waitForAllJobsCompleted(ZSTDMT_CCtx* zcs) size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx) { if (mtctx==NULL) return 0; /* compatible with free on NULL */ - POOL_free(mtctx->factory); - if (!mtctx->allJobsCompleted) { - ZSTDMT_waitForAllJobsCompleted(mtctx); - ZSTDMT_releaseAllJobResources(mtctx); /* stop workers first */ - } - ZSTDMT_freeBufferPool(mtctx->bufPool); /* release job resources into pools first */ + POOL_free(mtctx->factory); /* stop and free worker threads */ + ZSTDMT_releaseAllJobResources(mtctx); /* release job resources into pools first */ ZSTD_free(mtctx->jobs, mtctx->cMem); + ZSTDMT_freeBufferPool(mtctx->bufPool); ZSTDMT_freeCCtxPool(mtctx->cctxPool); ZSTD_freeCDict(mtctx->cdictLocal); ZSTD_pthread_mutex_destroy(&mtctx->jobCompleted_mutex);