summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-06-01 15:51:57 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-06-01 15:51:57 +0200
commit9020647cdcdb0ef132491838e36c870f4e4e90ea (patch)
tree98e0326c112b8a219676c8f717f9e1245ea55ef7
parentfd46d10a4f49da35758ab9201f6f863d69d5d4f5 (diff)
downloadrsyslog-9020647cdcdb0ef132491838e36c870f4e4e90ea.tar.gz
rsyslog-9020647cdcdb0ef132491838e36c870f4e4e90ea.tar.xz
rsyslog-9020647cdcdb0ef132491838e36c870f4e4e90ea.zip
some better code to handle queue congestion
This is a minor optimization to spare some cycles if the timeout is set to immediate discard
-rw-r--r--runtime/queue.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/runtime/queue.c b/runtime/queue.c
index 9d92af36..d78ab2e3 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -2323,20 +2323,25 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr)
while( (pThis->iMaxQueueSize > 0 && pThis->iQueueSize >= pThis->iMaxQueueSize)
|| (pThis->qType == QUEUETYPE_DISK && pThis->sizeOnDiskMax != 0
&& pThis->tVars.disk.sizeOnDisk > pThis->sizeOnDiskMax)) {
- DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - waiting to drain.\n");
- if(glbl.GetGlobalInputTermState()) {
- DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL, discard due to FORCE_TERM.\n");
- ABORT_FINALIZE(RS_RET_FORCE_TERM);
- }
- timeoutComp(&t, pThis->toEnq);
STATSCOUNTER_INC(pThis->ctrFull, pThis->mutCtrFull);
-// TODO : handle enqOnly => discard!
- if(pthread_cond_timedwait(&pThis->notFull, pThis->mut, &t) != 0) {
- DBGOPRINT((obj_t*) pThis, "enqueueMsg: cond timeout, dropping message!\n");
+ if(pThis->toEnq == 0 || pThis->bEnqOnly) {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - configured for immediate discarding.\n");
objDestruct(pUsr);
ABORT_FINALIZE(RS_RET_QUEUE_FULL);
- }
+ } else {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - waiting %dms to drain.\n", pThis->toEnq);
+ if(glbl.GetGlobalInputTermState()) {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL, discard due to FORCE_TERM.\n");
+ ABORT_FINALIZE(RS_RET_FORCE_TERM);
+ }
+ timeoutComp(&t, pThis->toEnq);
+ if(pthread_cond_timedwait(&pThis->notFull, pThis->mut, &t) != 0) {
+ DBGOPRINT((obj_t*) pThis, "enqueueMsg: cond timeout, dropping message!\n");
+ objDestruct(pUsr);
+ ABORT_FINALIZE(RS_RET_QUEUE_FULL);
+ }
dbgoprint((obj_t*) pThis, "enqueueMsg: wait solved queue full condition, enqueing\n");
+ }
}
/* and finally enqueue the message */