summaryrefslogtreecommitdiffstats
path: root/queue.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-14 14:18:36 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-14 14:18:36 +0000
commit3a40f52f897e8e3ef7fa665504fbbe557420fb59 (patch)
treef591bf82de68d0242b6157beb894e85f47fdad6e /queue.c
parent1b4a1902031babbb3907cd0e73d86c1fa0da0a3d (diff)
downloadrsyslog-3a40f52f897e8e3ef7fa665504fbbe557420fb59.tar.gz
rsyslog-3a40f52f897e8e3ef7fa665504fbbe557420fb59.tar.xz
rsyslog-3a40f52f897e8e3ef7fa665504fbbe557420fb59.zip
implemented $MainMsgQueueDiscardMar and $MainMsgQueueDiscardSeverity (but
serverity needs to be specified numerically for the time being)
Diffstat (limited to 'queue.c')
-rw-r--r--queue.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/queue.c b/queue.c
index 8010a45d..3559835b 100644
--- a/queue.c
+++ b/queue.c
@@ -1051,6 +1051,8 @@ queueEnqObj(queue_t *pThis, void *pUsr)
int iCancelStateSave;
int i;
struct timespec t;
+ int iSeverity = 8;
+ rsRetVal iRetLocal;
assert(pThis != NULL);
@@ -1064,13 +1066,28 @@ queueEnqObj(queue_t *pThis, void *pUsr)
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave);
pthread_mutex_lock(pThis->mut);
}
+
+ if(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",
+ queueGetID(pThis), pThis->iQueueSize, iSeverity);
+ objDestruct(pUsr);
+ ABORT_FINALIZE(RS_RET_QUEUE_FULL);
+ } else {
+ dbgprintf("Queue 0x%lx: queue nearly full (%d entries), but could not drop msg "
+ "(iRet: %d, severity %d)\n", queueGetID(pThis), pThis->iQueueSize,
+ iRetLocal, iSeverity);
+ }
+ }
+
while(pThis->iQueueSize >= pThis->iMaxQueueSize) {
- dbgprintf("Queue 0x%lx: enqueueMsg: queue FULL - waiting to drain.\n", (unsigned long) pThis);
+ dbgprintf("Queue 0x%lx: enqueueMsg: queue FULL - waiting to drain.\n", queueGetID(pThis));
queueTimeoutComp(&t, pThis->toEnq);
if(pthread_cond_timedwait (pThis->notFull,
pThis->mut, &t) != 0) {
- dbgprintf("Queue 0x%lx: enqueueMsg: cond timeout, dropping message!\n", (unsigned long) pThis);
+ dbgprintf("Queue 0x%lx: enqueueMsg: cond timeout, dropping message!\n", queueGetID(pThis));
objDestruct(pUsr);
ABORT_FINALIZE(RS_RET_QUEUE_FULL);
}