fixed one race scenario
diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 91f1580..68f9111 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c
@@ -837,6 +837,7 @@ job->cSize += lastCBlockSize; job->consumed = job->src.size; /* when job->consumed == job->src.size , compression job is presumed completed */ if (job->flush_mutex != NULL) { + assert(job->flush_cond != NULL); ZSTD_pthread_mutex_unlock(&job->job_mutex); ZSTD_PTHREAD_MUTEX_LOCK(job->flush_mutex); ZSTD_pthread_cond_signal(job->flush_cond); /* warns some more data is ready to be flushed */ @@ -1603,8 +1604,6 @@ DEBUGLOG(5, "dstBuffer released"); mtctx->jobs[wJobID].dstBuff = g_nullBuffer; mtctx->jobs[wJobID].cSize = 0; /* ensure this job slot is considered "not started" in future check */ - mtctx->jobs[wJobID].flush_mutex = NULL; - mtctx->jobs[wJobID].flush_cond = NULL; mtctx->consumed += srcSize; mtctx->produced += cSize; mtctx->doneJobID++;
diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c index b8290fe..e87a523 100644 --- a/tests/zstreamtest.c +++ b/tests/zstreamtest.c
@@ -2900,7 +2900,7 @@ U32 lseed; int opaqueAPI; const BYTE* srcBuffer; - size_t totalTestSize, totalGenSize, cSize; + size_t totalTestSize, totalGenSize, cSize=0; XXH64_state_t xxhState; U64 crcOrig; U32 resetAllowed = 1;