summaryrefslogtreecommitdiffstats
path: root/runtime/queue.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:38:31 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-07-24 11:38:31 +0200
commit87311d12771fc94e2d324e73922bd5e0b07de64e (patch)
treee3b1dbb75ab98684fc483b0f4bcd3cea7b282a94 /runtime/queue.c
parented04d8f8789818b83046f10c1b2bd0cae0a0ffdd (diff)
parentf043778bdc23c7b2baf18c1fc35ba47fa4d8386c (diff)
downloadrsyslog-87311d12771fc94e2d324e73922bd5e0b07de64e.tar.gz
rsyslog-87311d12771fc94e2d324e73922bd5e0b07de64e.tar.bz2
rsyslog-87311d12771fc94e2d324e73922bd5e0b07de64e.zip
Merge branch 'v5-stable'
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 34935403..896383d5 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -1829,6 +1829,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);
@@ -1838,6 +1839,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);
@@ -1856,10 +1858,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;
}