summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:38:01 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:38:01 +0200
commit7c1ad1c77cc3884931bd2c9e2d2f45db892a15a0 (patch)
tree4bf26b42e0157d62ac70c38bd783a3b35e83ecc3
parent0253f5ea381d1ff5da162359e16ec7c010fc18a3 (diff)
parentf043778bdc23c7b2baf18c1fc35ba47fa4d8386c (diff)
downloadrsyslog-7c1ad1c77cc3884931bd2c9e2d2f45db892a15a0.zip
rsyslog-7c1ad1c77cc3884931bd2c9e2d2f45db892a15a0.tar.gz
rsyslog-7c1ad1c77cc3884931bd2c9e2d2f45db892a15a0.tar.xz
Merge branch 'v5-stable' into v6-stable
-rw-r--r--ChangeLog1
-rw-r--r--runtime/queue.c8
-rw-r--r--runtime/stream.c10
3 files changed, 10 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 753ff73..fd2bd3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -306,6 +306,7 @@ Version 5.9.0 [V5-DEVEL] (rgerhards), 2011-03-??
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=236
---------------------------------------------------------------------------
Version 5.8.13 [V5-stable] 2012-06-??
+- bugfix: DA queue could cause abort
- bugfix: "last message repeated n times" message was missing hostname
Thanks to Zdenek Salvet for finding this bug and to Bodik for reporting
- bugfix "$PreserveFQDN on" was not honored in some modules
diff --git a/runtime/queue.c b/runtime/queue.c
index d78ab2e..280ebd9 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -1743,6 +1743,7 @@ ConsumerDA(qqueue_t *pThis, wti_t *pWti)
{
int i;
int iCancelStateSave;
+ int bNeedReLock = 0; /**< do we need to lock the mutex again? */
DEFiRet;
ISOBJ_TYPE_assert(pThis, qqueue);
@@ -1752,6 +1753,7 @@ ConsumerDA(qqueue_t *pThis, wti_t *pWti)
/* we now have a non-idle batch of work, so we can release the queue mutex and process it */
d_pthread_mutex_unlock(pThis->mut);
+ bNeedReLock = 1;
/* at this spot, we may be cancelled */
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &iCancelStateSave);
@@ -1770,10 +1772,10 @@ ConsumerDA(qqueue_t *pThis, wti_t *pWti)
/* but now cancellation is no longer permitted */
pthread_setcancelstate(iCancelStateSave, NULL);
- /* now we are done, but need to re-aquire the mutex */
- d_pthread_mutex_lock(pThis->mut);
-
finalize_it:
+ /* now we are done, but potentially need to re-aquire the mutex */
+ if(bNeedReLock)
+ d_pthread_mutex_lock(pThis->mut);
DBGOPRINT((obj_t*) pThis, "DAConsumer returns with iRet %d\n", iRet);
RETiRet;
}
diff --git a/runtime/stream.c b/runtime/stream.c
index 6b88d3f..bb1a0a4 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -16,7 +16,7 @@
* it turns out to be problematic. Then, we need to quasi-refcount the number of accesses
* to the object.
*
- * Copyright 2008, 2009 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2008-2012 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -361,7 +361,7 @@ static rsRetVal strmCloseFile(strm_t *pThis)
pThis->fdDir = -1;
}
- if(pThis->bDeleteOnClose) {
+ if(pThis->bDeleteOnClose && pThis->pszCurrFName != NULL) {
if(unlink((char*) pThis->pszCurrFName) == -1) {
char errStr[1024];
int err = errno;
@@ -369,14 +369,12 @@ static rsRetVal strmCloseFile(strm_t *pThis)
DBGPRINTF("error %d unlinking '%s' - ignored: %s\n",
errno, pThis->pszCurrFName, errStr);
}
- }
-
- pThis->iCurrOffs = 0; /* we are back at begin of file */
- if(pThis->pszCurrFName != NULL) {
free(pThis->pszCurrFName); /* no longer needed in any case (just for open) */
pThis->pszCurrFName = NULL;
}
+ pThis->iCurrOffs = 0; /* we are back at begin of file */
+
RETiRet;
}