summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-07-16 10:56:04 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-07-16 10:56:04 +0200
commit1ea14f211ba0e7351c7da745a5411c7efdeb3cbd (patch)
treea9e70b988eb768f6374e2dcb3b8069e8f36c003f
parent199f01614ca45854a820878b5d0f91f729fc379c (diff)
parent1c6449022c423c13a8828028cb68afe30e3c2f46 (diff)
downloadrsyslog-1ea14f211ba0e7351c7da745a5411c7efdeb3cbd.tar.gz
rsyslog-1ea14f211ba0e7351c7da745a5411c7efdeb3cbd.tar.bz2
rsyslog-1ea14f211ba0e7351c7da745a5411c7efdeb3cbd.zip
Merge branch 'v7-stable'
-rw-r--r--runtime/queue.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/runtime/queue.c b/runtime/queue.c
index 0f71ff13..c9c236fd 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -1952,8 +1952,32 @@ ConsumerDA(qqueue_t *pThis, wti_t *pWti)
pthread_setcancelstate(iCancelStateSave, NULL);
finalize_it:
- if(iRet != RS_RET_OK && iRet != RS_RET_ERR_QUEUE_EMERGENCY) {
- iRet = RS_RET_OK;
+ /* Check the last return state of qqueueEnqMsg. If an error was returned, we acknowledge it only.
+ * Unless the error code is RS_RET_ERR_QUEUE_EMERGENCY, we reset the return state to RS_RET_OK.
+ * Otherwise the Caller functions would run into an infinite Loop trying to enqueue the
+ * same messages over and over again.
+ *
+ * However we do NOT overwrite positive return states like
+ * RS_RET_TERMINATE_NOW,
+ * RS_RET_NO_RUN,
+ * RS_RET_IDLE,
+ * RS_RET_TERMINATE_WHEN_IDLE
+ * These return states are important for Queue handling of the upper laying functions.
+ * RGer: Note that checking for iRet < 0 is a bit bold. In theory, positive iRet
+ * values are "OK" states, and things that the caller shall deal with. However,
+ * this has not been done so consistently. Andre convinced me that the current
+ * code is an elegant solution. However, if problems with queue workers and/or
+ * shutdown come up, this code here should be looked at suspiciously. In those
+ * cases it may work out to check all status codes explicitely, just to avoid
+ * a pitfall due to unexpected states being passed on to the caller.
+ */
+ if( iRet != RS_RET_OK &&
+ iRet != RS_RET_ERR_QUEUE_EMERGENCY &&
+ iRet < 0) {
+ DBGOPRINT((obj_t*) pThis, "ConsumerDA:qqueueEnqMsg Resetting iRet from %d back to RS_RET_OK\n", iRet);
+ iRet = RS_RET_OK;
+ } else {
+ DBGOPRINT((obj_t*) pThis, "ConsumerDA:qqueueEnqMsg returns with iRet %d\n", iRet);
}
/* now we are done, but potentially need to re-aquire the mutex */