zstdmt : fixed : buffer dst0 wasn't properly set to null after usage
now it's possible to unconditionnally invoke ZSTD_releaseAllJobRessources() wether previous compression was completed correctly or not.
This commit is contained in:
@@ -115,9 +115,12 @@ static ZSTDMT_bufferPool* ZSTDMT_createBufferPool(unsigned nbThreads, ZSTD_custo
|
|||||||
static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool)
|
static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool)
|
||||||
{
|
{
|
||||||
unsigned u;
|
unsigned u;
|
||||||
|
DEBUGLOG(3, "ZSTDMT_freeBufferPool (address:%08X)", (U32)bufPool);
|
||||||
if (!bufPool) return; /* compatibility with free on NULL */
|
if (!bufPool) return; /* compatibility with free on NULL */
|
||||||
for (u=0; u<bufPool->totalBuffers; u++)
|
for (u=0; u<bufPool->totalBuffers; u++) {
|
||||||
|
DEBUGLOG(4, "free buffer %2u (address:%08X)", u, (U32)bufPool->bTable[u].start);
|
||||||
ZSTD_free(bufPool->bTable[u].start, bufPool->cMem);
|
ZSTD_free(bufPool->bTable[u].start, bufPool->cMem);
|
||||||
|
}
|
||||||
ZSTD_pthread_mutex_destroy(&bufPool->poolMutex);
|
ZSTD_pthread_mutex_destroy(&bufPool->poolMutex);
|
||||||
ZSTD_free(bufPool, bufPool->cMem);
|
ZSTD_free(bufPool, bufPool->cMem);
|
||||||
}
|
}
|
||||||
@@ -485,12 +488,15 @@ static void ZSTDMT_releaseAllJobResources(ZSTDMT_CCtx* mtctx)
|
|||||||
unsigned jobID;
|
unsigned jobID;
|
||||||
DEBUGLOG(3, "ZSTDMT_releaseAllJobResources");
|
DEBUGLOG(3, "ZSTDMT_releaseAllJobResources");
|
||||||
for (jobID=0; jobID <= mtctx->jobIDMask; jobID++) {
|
for (jobID=0; jobID <= mtctx->jobIDMask; jobID++) {
|
||||||
|
DEBUGLOG(4, "job%02u: release dst address %08X", jobID, (U32)mtctx->jobs[jobID].dstBuff.start);
|
||||||
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].dstBuff);
|
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].dstBuff);
|
||||||
mtctx->jobs[jobID].dstBuff = g_nullBuffer;
|
mtctx->jobs[jobID].dstBuff = g_nullBuffer;
|
||||||
|
DEBUGLOG(4, "job%02u: release src address %08X", jobID, (U32)mtctx->jobs[jobID].src.start);
|
||||||
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].src);
|
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].src);
|
||||||
mtctx->jobs[jobID].src = g_nullBuffer;
|
mtctx->jobs[jobID].src = g_nullBuffer;
|
||||||
}
|
}
|
||||||
memset(mtctx->jobs, 0, (mtctx->jobIDMask+1)*sizeof(ZSTDMT_jobDescription));
|
memset(mtctx->jobs, 0, (mtctx->jobIDMask+1)*sizeof(ZSTDMT_jobDescription));
|
||||||
|
DEBUGLOG(4, "input: release address %08X", (U32)mtctx->inBuff.buffer.start);
|
||||||
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->inBuff.buffer);
|
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->inBuff.buffer);
|
||||||
mtctx->inBuff.buffer = g_nullBuffer;
|
mtctx->inBuff.buffer = g_nullBuffer;
|
||||||
mtctx->allJobsCompleted = 1;
|
mtctx->allJobsCompleted = 1;
|
||||||
@@ -684,9 +690,8 @@ static size_t ZSTDMT_compress_advanced_internal(
|
|||||||
if (chunkID >= compressWithinDst) { /* chunk compressed into its own buffer, which must be released */
|
if (chunkID >= compressWithinDst) { /* chunk compressed into its own buffer, which must be released */
|
||||||
DEBUGLOG(5, "releasing buffer %u>=%u", chunkID, compressWithinDst);
|
DEBUGLOG(5, "releasing buffer %u>=%u", chunkID, compressWithinDst);
|
||||||
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[chunkID].dstBuff);
|
ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[chunkID].dstBuff);
|
||||||
}
|
} }
|
||||||
mtctx->jobs[chunkID].dstBuff = g_nullBuffer;
|
mtctx->jobs[chunkID].dstBuff = g_nullBuffer;
|
||||||
}
|
|
||||||
dstPos += cSize ;
|
dstPos += cSize ;
|
||||||
}
|
}
|
||||||
} /* for (chunkID=0; chunkID<nbChunks; chunkID++) */
|
} /* for (chunkID=0; chunkID<nbChunks; chunkID++) */
|
||||||
|
|||||||
+1
-2
@@ -510,8 +510,7 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
/* only use the first half so we don't push against size limit of compressedBuffer */
|
/* only use the first half so we don't push against size limit of compressedBuffer */
|
||||||
size_t const segSize = (CNBuffSize / 2) / segs;
|
size_t const segSize = (CNBuffSize / 2) / segs;
|
||||||
for (i = 0; i < segs; i++) {
|
for (i = 0; i < segs; i++) {
|
||||||
CHECK_V(r,
|
CHECK_V(r, ZSTD_compress(
|
||||||
ZSTD_compress(
|
|
||||||
(BYTE *)compressedBuffer + off, CNBuffSize - off,
|
(BYTE *)compressedBuffer + off, CNBuffSize - off,
|
||||||
(BYTE *)CNBuffer + segSize * i,
|
(BYTE *)CNBuffer + segSize * i,
|
||||||
segSize, 5));
|
segSize, 5));
|
||||||
|
|||||||
Reference in New Issue
Block a user