summaryrefslogtreecommitdiffstats
path: root/runtime/queue.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:21:57 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:21:57 +0200
commitef91a26de7de0e5b39b963f984b05acbaa691460 (patch)
treec46960687c8665926fc2bc0e5828cdf6892eccb7 /runtime/queue.c
parentfdbc4cb666b4fc92562ece1fba97227c40237e04 (diff)
parentf043778bdc23c7b2baf18c1fc35ba47fa4d8386c (diff)
downloadrsyslog-ef91a26de7de0e5b39b963f984b05acbaa691460.tar.gz
rsyslog-ef91a26de7de0e5b39b963f984b05acbaa691460.tar.xz
rsyslog-ef91a26de7de0e5b39b963f984b05acbaa691460.zip
Merge branch 'v5-stable' into beta
Diffstat (limited to 'runtime/queue.c')
-rw-r--r--runtime/queue.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/queue.c b/runtime/queue.c
index 5d69da24..3c91fd02 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -1878,6 +1878,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);
@@ -1887,6 +1888,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);
@@ -1905,10 +1907,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;
}