summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-07-07 17:18:51 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-07-07 17:18:51 +0200
commit26227091faac8c3cc9bc282eb4e4fc408635f8d2 (patch)
tree72670464c51c036d35bebf0a3d273a9f43f3ba29 /runtime
parentc444f964490ed941d734769e7bca21a92db998cd (diff)
downloadrsyslog-26227091faac8c3cc9bc282eb4e4fc408635f8d2.tar.gz
rsyslog-26227091faac8c3cc9bc282eb4e4fc408635f8d2.tar.xz
rsyslog-26227091faac8c3cc9bc282eb4e4fc408635f8d2.zip
fixed a bug introduced today that lead to an abort in queue disk mode
Diffstat (limited to 'runtime')
-rw-r--r--runtime/debug.c2
-rw-r--r--runtime/stream.c21
-rw-r--r--runtime/stream.h1
3 files changed, 14 insertions, 10 deletions
diff --git a/runtime/debug.c b/runtime/debug.c
index ded1c218..807fd3f7 100644
--- a/runtime/debug.c
+++ b/runtime/debug.c
@@ -778,7 +778,7 @@ static void dbgCallStackPrint(dbgThrdInfo_t *pThrd)
/* print all threads call stacks
*/
-static void dbgCallStackPrintAll(void)
+void dbgCallStackPrintAll(void)
{
dbgThrdInfo_t *pThrd;
/* stack info */
diff --git a/runtime/stream.c b/runtime/stream.c
index eae36796..9f363257 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -276,11 +276,13 @@ finalize_it:
static inline void
strmWaitAsyncWriterDone(strm_t *pThis)
{
+ BEGINfunc
if(pThis->bAsyncWrite) {
/* awake writer thread and make it write out everything */
pthread_cond_signal(&pThis->notEmpty);
d_pthread_cond_wait(&pThis->isEmpty, &pThis->mut);
}
+ ENDfunc
}
@@ -296,10 +298,16 @@ static rsRetVal strmCloseFile(strm_t *pThis)
ASSERT(pThis->fd != -1);
dbgoprint((obj_t*) pThis, "file %d closing\n", pThis->fd);
- if(pThis->tOperationsMode != STREAMMODE_READ)
- strmFlush(pThis);
-
- strmWaitAsyncWriterDone(pThis);
+ dbgCallStackPrintAll();
+ if(!pThis->bInClose && pThis->tOperationsMode != STREAMMODE_READ) {
+ pThis->bInClose = 1;
+ if(pThis->bAsyncWrite) {
+ strmFlush(pThis);
+ } else {
+ strmWaitAsyncWriterDone(pThis);
+ }
+ pThis->bInClose = 0;
+ }
close(pThis->fd);
pThis->fd = -1;
@@ -796,11 +804,6 @@ finalize_it:
/* write memory buffer to a stream object.
- * To support direct writes of large objects, this method may be called
- * with a buffer pointing to some region other than the stream buffer itself.
- * However, in that case the stream buffer must be empty (strmFlush() has to
- * be called before), because we would otherwise mess up with the sequence
- * inside the stream. -- rgerhards, 2008-01-10
*/
static inline rsRetVal
doWriteInternal(strm_t *pThis, uchar *pBuf, size_t lenBuf)
diff --git a/runtime/stream.h b/runtime/stream.h
index 2c1ac255..1efd29b5 100644
--- a/runtime/stream.h
+++ b/runtime/stream.h
@@ -118,6 +118,7 @@ typedef struct strm_s {
size_t iBufPtr; /* pointer into current buffer */
int iUngetC; /* char set via UngetChar() call or -1 if none set */
bool bInRecord; /* if 1, indicates that we are currently writing a not-yet complete record */
+ bool bInClose; /* used to break "deadly close loops", tells us we are already inside a close */
int iZipLevel; /* zip level (0..9). If 0, zip is completely disabled */
Bytef *pZipBuf;
/* support for async flush procesing */