diff options
-rw-r--r-- | queue.c | 28 | ||||
-rw-r--r-- | syslogd.c | 4 |
2 files changed, 21 insertions, 11 deletions
@@ -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); @@ -408,7 +408,7 @@ static queue_t *pMsgQueue = NULL; /* the main message queue */ static int iMainMsgQueueSize = 10000; /* size of the main message queue above */ static int iMainMsgQHighWtrMark = 8000; /* high water mark for disk-assisted queues */ static int iMainMsgQLowWtrMark = 2000; /* low water mark for disk-assisted queues */ -static int iMainMsgQDiscardMark = 9750; /* begin to discard messages */ +static int iMainMsgQDiscardMark = 9800; /* begin to discard messages */ static int iMainMsgQDiscardSeverity = 4; /* discard warning and above */ static int iMainMsgQueueNumWorkers = 1; /* number of worker threads for the mm queue above */ static queueType_t MainMsgQueType = QUEUETYPE_FIXED_ARRAY; /* type of the main message queue above */ @@ -521,7 +521,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a iMainMsgQueueSize = 10000; iMainMsgQHighWtrMark = 8000; iMainMsgQLowWtrMark = 2000; - iMainMsgQDiscardMark = 9750; + iMainMsgQDiscardMark = 9800; iMainMsgQDiscardSeverity = 4; iMainMsgQueMaxFileSize = 1024 * 1024; iMainMsgQueueNumWorkers = 1; |