summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-10 09:52:49 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-10 09:52:49 +0100
commit6c43f93022caa3feaa7b4fa3d88ca31746fd94cf (patch)
treef443af410fbc1bde7d2e2bc80cd401495b788bb9 /runtime/stream.c
parent5996414f04118dec4f1dcc12c88ee8c68f6e89ad (diff)
downloadrsyslog-6c43f93022caa3feaa7b4fa3d88ca31746fd94cf.tar.gz
rsyslog-6c43f93022caa3feaa7b4fa3d88ca31746fd94cf.tar.xz
rsyslog-6c43f93022caa3feaa7b4fa3d88ca31746fd94cf.zip
fixed regression introduced with previous commit
disk queue mode did no longer work correctly. A side-effect of this commit here is slightly cleaned-up (and more elegant) code for circular files.
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 5396bae0..c6c8273e 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -318,13 +318,11 @@ static rsRetVal strmCloseFile(strm_t *pThis)
ASSERT(pThis != NULL);
dbgoprint((obj_t*) pThis, "file %d closing\n", pThis->fd);
- if(!pThis->bInClose && pThis->tOperationsMode != STREAMMODE_READ) {
- pThis->bInClose = 1;
+ if(pThis->tOperationsMode != STREAMMODE_READ) {
strmFlush(pThis);
if(pThis->bAsyncWrite) {
strmWaitAsyncWriterDone(pThis);
}
- pThis->bInClose = 0;
}
close(pThis->fd);
@@ -882,13 +880,22 @@ strmSchedWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf)
ASSERT(pThis != NULL);
+ /* we need to reset the buffer pointer BEFORE calling the actual write
+ * function. Otherwise, in circular mode, the write function will
+ * potentially close the file, then close will flush and as the
+ * buffer pointer is nonzero, will re-call into this code here. In
+ * the end result, we than have a problem (and things are screwed
+ * up). So we reset the buffer pointer first, and all this can
+ * not happen. It is safe to do so, because that pointer is NOT
+ * used inside the write functions. -- rgerhads, 2010-03-10
+ */
+ pThis->iBufPtr = 0; /* we are at the begin of a new buffer */
if(pThis->bAsyncWrite) {
CHKiRet(doAsyncWriteInternal(pThis, lenBuf));
} else {
CHKiRet(doWriteInternal(pThis, pBuf, lenBuf));
}
- pThis->iBufPtr = 0; /* we are at the begin of a new buffer */
finalize_it:
RETiRet;