summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-10-07 11:46:46 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-10-07 11:46:46 +0200
commitcdecd7e524a5114ccff4f2909b32738bdb33c6ea (patch)
tree16f8b629df7d6e81d84a4be2332b77b74e513437 /runtime
parent7b3c05da9f126063384c80e9dd6fd5b2ae610074 (diff)
downloadrsyslog-cdecd7e524a5114ccff4f2909b32738bdb33c6ea.tar.gz
rsyslog-cdecd7e524a5114ccff4f2909b32738bdb33c6ea.tar.xz
rsyslog-cdecd7e524a5114ccff4f2909b32738bdb33c6ea.zip
slightly improved lock contention situation by moving out of
the critical section what could so with acceptable consequences
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queue.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/queue.c b/runtime/queue.c
index 76c2f10f..f5f770b3 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -2101,6 +2101,15 @@ queueEnqObj(queue_t *pThis, flowControl_t flowCtlType, void *pUsr)
ISOBJ_TYPE_assert(pThis, queue);
+ /* first check if we need to discard this message (which will cause CHKiRet() to exit)
+ * rgerhards, 2008-10-07: It is OK to do this outside of mutex protection. The iQueueSize
+ * and bRunsDA parameters may not reflect the correct settings here, but they are
+ * "good enough" in the sense that they can be used to drive the decision. Valgrind's
+ * threading tools may point this access to be an error, but this is done
+ * intentional. I do not see this causes problems to us.
+ */
+ CHKiRet(queueChkDiscardMsg(pThis, pThis->iQueueSize, pThis->bRunsDA, pUsr));
+
/* Please note that this function is not cancel-safe and consequently
* sets the calling thread's cancelibility state to PTHREAD_CANCEL_DISABLE
* during its execution. If that is not done, race conditions occur if the
@@ -2112,9 +2121,6 @@ queueEnqObj(queue_t *pThis, flowControl_t flowCtlType, void *pUsr)
d_pthread_mutex_lock(pThis->mut);
}
- /* first check if we need to discard this message (which will cause CHKiRet() to exit) */
- CHKiRet(queueChkDiscardMsg(pThis, pThis->iQueueSize, pThis->bRunsDA, pUsr));
-
/* then check if we need to add an assistance disk queue */
if(pThis->bIsDA)
CHKiRet(queueChkStrtDA(pThis));