From: Paul Cruz Date: Wed, 26 Jul 2017 17:34:48 +0000 (-0700) Subject: moved reset of completion to right after wait X-Git-Tag: v1.3.1^2~13^2^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a959cc881a65b4ef250b4f963924c04c6760be0d;p=thirdparty%2Fzstd.git moved reset of completion to right after wait --- diff --git a/contrib/adaptive-compression/adapt.c b/contrib/adaptive-compression/adapt.c index d75660806..237bb4306 100644 --- a/contrib/adaptive-compression/adapt.c +++ b/contrib/adaptive-compression/adapt.c @@ -678,10 +678,6 @@ static int createCompressionJob(adaptCCtx* ctx, size_t srcSize, int last) jobDescription* const job = &ctx->jobs[nextJobIndex]; - /* reset create completion */ - pthread_mutex_lock(&ctx->createCompletion_mutex.pMutex); - ctx->createCompletion = 0; - pthread_mutex_unlock(&ctx->createCompletion_mutex.pMutex); job->compressionLevel = ctx->compressionLevel; job->src.size = srcSize; job->jobID = nextJob; @@ -761,6 +757,11 @@ static int performCompression(adaptCCtx* ctx, FILE* const srcFile, outputThreadA } pthread_mutex_unlock(&ctx->jobCompressed_mutex.pMutex); + /* reset create completion */ + pthread_mutex_lock(&ctx->createCompletion_mutex.pMutex); + ctx->createCompletion = 0; + pthread_mutex_unlock(&ctx->createCompletion_mutex.pMutex); + while (remaining != 0 && !feof(srcFile)) { size_t const ret = fread(ctx->input.buffer.start + ctx->input.filled + pos, 1, readBlockSize, srcFile); if (ret != readBlockSize && !feof(srcFile)) {