From 51ec17e88826559b493d7a57dd9cb6ea547ed3f3 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 14 Jan 2008 15:12:12 +0000 Subject: also implemented $MainMsgQueueDiscardMark logic on dequeue, changed defaults --- queue.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'queue.c') 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); -- cgit