bugfix: dynafile zip files could be corrupted

This could happen if a dynafile was destructed before the first write.
In practice, this could happen if few lines were written to a file and
it then became evicted from the dynafile cache. This would probably
look very random, because it depended on the timing in regard to
message volume and dynafile cache size.
This commit is contained in:
Rainer Gerhards 2012-11-05 13:01:25 +01:00
parent 9ab1503180
commit 557f20f841
2 changed files with 13 additions and 9 deletions

View File

@ -1,3 +1,9 @@
- bugfix: dynafile zip files could be corrupted
This could happen if a dynafile was destructed before the first write.
In practice, this could happen if few lines were written to a file and
it then became evicted from the dynafile cache. This would probably
look very random, because it depended on the timing in regard to
message volume and dynafile cache size.
---------------------------------------------------------------------------
Version 7.3.2 [devel] 2012-10-30
- mmnormalize: support for v6+ config interface added

View File

@ -343,6 +343,9 @@ static rsRetVal strmCloseFile(strm_t *pThis)
if(pThis->tOperationsMode != STREAMMODE_READ) {
strmFlushInternal(pThis, 0);
if(pThis->iZipLevel) {
doZipFinish(pThis);
}
if(pThis->bAsyncWrite) {
strmWaitAsyncWriterDone(pThis);
}
@ -780,9 +783,6 @@ BEGINobjDestruct(strm) /* be sure to specify the object type also in END and COD
int i;
CODESTARTobjDestruct(strm)
/* we need to stop the ZIP writer */
if(pThis->iZipLevel) {
doZipFinish(pThis);
}
if(pThis->bAsyncWrite)
/* Note: mutex will be unlocked in stopWriter! */
d_pthread_mutex_lock(&pThis->mut);
@ -1231,11 +1231,9 @@ doZipFinish(strm_t *pThis)
unsigned outavail;
assert(pThis != NULL);
if(!pThis->bzInitDone) {
FINALIZE;
}
if(!pThis->bzInitDone)
goto done;
dbgprintf("AAAA: doZipFinish() called\n");
pThis->zstrm.avail_in = 0;
/* run deflate() on buffer until everything has been compressed */
do {
@ -1257,7 +1255,7 @@ finalize_it:
}
pThis->bzInitDone = 0;
RETiRet;
done: RETiRet;
}
/* flush stream output buffer to persistent storage. This can be called at any time
@ -1423,7 +1421,7 @@ strmWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf)
ASSERT(pThis != NULL);
ASSERT(pBuf != NULL);
//DBGPRINTF("strmWrite(%p, '%65.65s', %ld);, disabled %d, sizelim %ld, size %lld\n", pThis, pBuf,lenBuf, pThis->bDisabled, pThis->iSizeLimit, pThis->iCurrOffs);
/* DEV DEBUG ONLY DBGPRINTF("strmWrite(%p[%s], '%65.65s', %ld);, disabled %d, sizelim %ld, size %lld\n", pThis, pThis->pszCurrFName, pBuf,(long) lenBuf, pThis->bDisabled, (long) pThis->iSizeLimit, (long long) pThis->iCurrOffs); */
if(pThis->bAsyncWrite)
d_pthread_mutex_lock(&pThis->mut);