summaryrefslogtreecommitdiffstats
path: root/queue.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-14 15:12:12 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-14 15:12:12 +0000
commit51ec17e88826559b493d7a57dd9cb6ea547ed3f3 (patch)
tree1ab24f0b8c342bbacd0519f5686b66c481259b15 /queue.c
parent3a40f52f897e8e3ef7fa665504fbbe557420fb59 (diff)
downloadrsyslog-51ec17e88826559b493d7a57dd9cb6ea547ed3f3.tar.gz
rsyslog-51ec17e88826559b493d7a57dd9cb6ea547ed3f3.tar.xz
rsyslog-51ec17e88826559b493d7a57dd9cb6ea547ed3f3.zip
also implemented $MainMsgQueueDiscardMark logic on dequeue, changed
defaults
Diffstat (limited to 'queue.c')
-rw-r--r--queue.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/queue.c b/queue.c
index 3559835b..d7aa464a 100644
--- a/queue.c
+++ b/queue.c
@@ -627,6 +627,8 @@ queueWorker(void *arg)
sigset_t sigSet;
int iMyThrdIndx; /* index for this thread in queue thread table */
int iCancelStateSave;
+ int iSeverity;
+ rsRetVal iRetLocal;
assert(pThis != NULL);
@@ -677,15 +679,23 @@ queueWorker(void *arg)
* rgerhards, 2008-01-03
*/
if(iRet == RS_RET_OK) {
- rsRetVal iRetLocal;
- dbgprintf("Queue 0x%lx/w%d: worker executes consumer...\n",
- queueGetID(pThis), iMyThrdIndx);
- iRetLocal = pThis->pConsumer(pUsr);
- dbgprintf("Queue 0x%lx/w%d: worker: consumer returnd %d\n",
- queueGetID(pThis), iMyThrdIndx, iRetLocal);
- if(iRetLocal != RS_RET_OK)
- dbgprintf("Queue 0x%lx/w%d: Consumer returned iRet %d\n",
- (unsigned long) pThis, iMyThrdIndx, iRetLocal);
+ /* do a quick check if we need to drain the queue */
+ if(pThis->iQueueSize >= pThis->iDiscardMrk) {
+ iRetLocal = objGetSeverity(pUsr, &iSeverity);
+ if(iRetLocal == RS_RET_OK && iSeverity >= pThis->iDiscardSeverity) {
+ dbgprintf("Queue 0x%lx/w%d: dequeue/queue nearly full (%d entries), "
+ "discarded severity %d message\n",
+ queueGetID(pThis), iMyThrdIndx, pThis->iQueueSize, iSeverity);
+ objDestruct(pUsr);
+ }
+ } else {
+ dbgprintf("Queue 0x%lx/w%d: worker executes consumer...\n",
+ queueGetID(pThis), iMyThrdIndx);
+ iRetLocal = pThis->pConsumer(pUsr);
+ if(iRetLocal != RS_RET_OK)
+ dbgprintf("Queue 0x%lx/w%d: Consumer returned iRet %d\n",
+ queueGetID(pThis), iMyThrdIndx, iRetLocal);
+ }
} else {
dbgprintf("Queue 0x%lx/w%d: error %d dequeueing element - ignoring, but strange things "
"may happen\n", queueGetID(pThis), iMyThrdIndx, iRet);