summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
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/stream.c
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/stream.c')
-rw-r--r--runtime/stream.c21
1 files changed, 12 insertions, 9 deletions
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)