From 16eba18af23dad76e717ae9fde5dfea31ce6f2aa Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 14 Jan 2008 15:24:29 +0000 Subject: - implemented $MainMsgQueueDiscardMark == 0 --> disable Discard logic - implemented $MainMsgQueueSize == 0 --> no limit on queue size --- queue.c | 9 ++++++--- rsyslog.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/queue.c b/queue.c index d7aa464a..17992473 100644 --- a/queue.c +++ b/queue.c @@ -85,6 +85,9 @@ static rsRetVal qConstructFixedArray(queue_t *pThis) assert(pThis != NULL); + if(pThis->iMaxQueueSize == 0) + ABORT_FINALIZE(RS_RET_QSIZE_ZERO); + if((pThis->tVars.farray.pBuf = malloc(sizeof(void *) * pThis->iMaxQueueSize)) == NULL) { ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); } @@ -680,7 +683,7 @@ queueWorker(void *arg) */ if(iRet == RS_RET_OK) { /* do a quick check if we need to drain the queue */ - if(pThis->iQueueSize >= pThis->iDiscardMrk) { + if(pThis->iDiscardMrk > 0 && 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), " @@ -1077,7 +1080,7 @@ queueEnqObj(queue_t *pThis, void *pUsr) pthread_mutex_lock(pThis->mut); } - if(pThis->iQueueSize >= pThis->iDiscardMrk) { + if(pThis->iDiscardMrk > 0 && pThis->iQueueSize >= pThis->iDiscardMrk) { iRetLocal = objGetSeverity(pUsr, &iSeverity); if(iRetLocal == RS_RET_OK && iSeverity >= pThis->iDiscardSeverity) { dbgprintf("Queue 0x%lx: queue nearly full (%d entries), discarded severity %d message\n", @@ -1092,7 +1095,7 @@ queueEnqObj(queue_t *pThis, void *pUsr) } - while(pThis->iQueueSize >= pThis->iMaxQueueSize) { + while(pThis->iMaxQueueSize > 0 && pThis->iQueueSize >= pThis->iMaxQueueSize) { dbgprintf("Queue 0x%lx: enqueueMsg: queue FULL - waiting to drain.\n", queueGetID(pThis)); queueTimeoutComp(&t, pThis->toEnq); if(pthread_cond_timedwait (pThis->notFull, diff --git a/rsyslog.h b/rsyslog.h index 3e5c0397..a10cdf86 100644 --- a/rsyslog.h +++ b/rsyslog.h @@ -110,6 +110,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth RS_RET_NO_FILE_ACCESS = -2039, /**< covers EACCES error on file open() */ RS_RET_FILE_NOT_FOUND = -2040, /**< file not found */ RS_RET_TIMED_OUT = -2041, /**< timeout occured (not necessarily an error) */ + RS_RET_QSIZE_ZERO = -2042, /**< queue size is zero where this is not supported */ RS_RET_OK_DELETE_LISTENTRY = 1, /**< operation successful, but callee requested the deletion of an entry (special state) */ RS_RET_TERMINATE_NOW = 2, /**< operation successful, function is requested to terminate (mostly used with threads) */ RS_RET_NO_RUN = 3, /**< operation successful, but function does not like to be executed */ -- cgit v1.2.3