summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-19 07:37:56 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-19 07:37:56 +0100
commit3e0578605f7df8427aa5b70c2b4396504113fafc (patch)
tree39df3fbe362c46b1f00e699c9d33431deae0c9c7 /runtime/stream.c
parent44f670848a87fc59bffc0b8f433a2e2c798dc176 (diff)
downloadrsyslog-3e0578605f7df8427aa5b70c2b4396504113fafc.tar.gz
rsyslog-3e0578605f7df8427aa5b70c2b4396504113fafc.tar.xz
rsyslog-3e0578605f7df8427aa5b70c2b4396504113fafc.zip
bugfix: potential hang condition during filestream close
predicate was not properly checked when waiting for the background file writer
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 93f7fd58..88606db7 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -163,7 +163,7 @@ doSizeLimitProcessing(strm_t *pThis)
ASSERT(pThis->fd != -1);
if(pThis->iCurrOffs >= pThis->iSizeLimit) {
- /* strmClosefile() destroys the current file name, so we
+ /* strmCloseFile() destroys the current file name, so we
* need to preserve it.
*/
CHKmalloc(pszCurrFName = ustrdup(pThis->pszCurrFName));
@@ -296,8 +296,10 @@ 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);
+ while(pThis->iCnt > 0) {
+ pthread_cond_signal(&pThis->notEmpty);
+ d_pthread_cond_wait(&pThis->isEmpty, &pThis->mut);
+ }
}
ENDfunc
}
@@ -944,7 +946,7 @@ dbgprintf("XXX: asyncWriterThread iterating %s\n", pThis->pszFName);
continue; /* now we should have data */
}
bTimedOut = 0;
- timeoutComp(&t, pThis->iFlushInterval * 2000); /* *1000 millisconds */
+ timeoutComp(&t, pThis->iFlushInterval * 2000); /* *1000 millisconds */ // TODO: check the 2000?!?
if(pThis->bDoTimedWait) {
dbgprintf("asyncWriter thread going to timeout sleep\n");
if(pthread_cond_timedwait(&pThis->notEmpty, &pThis->mut, &t) != 0) {