summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-03 15:58:10 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-03 15:58:10 +0000
commit236e2a5f73de889692a7f4197257059ee805ebc9 (patch)
treec326c4ed414ae62c72ee20f1153c0067d68b4c37
parent0edfa2415457fca76cc85976a4bcf2ae54f2144d (diff)
downloadrsyslog-236e2a5f73de889692a7f4197257059ee805ebc9.tar.gz
rsyslog-236e2a5f73de889692a7f4197257059ee805ebc9.tar.xz
rsyslog-236e2a5f73de889692a7f4197257059ee805ebc9.zip
added $MainMsgQueueType config parameter
-rw-r--r--queue.c3
-rw-r--r--queue.h4
-rw-r--r--syslogd.c34
3 files changed, 34 insertions, 7 deletions
diff --git a/queue.c b/queue.c
index b8b4eeff..f4dc992c 100644
--- a/queue.c
+++ b/queue.c
@@ -314,7 +314,8 @@ rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize,
/* now fire up the worker thread */
pThis->bDoRun = 1; /* we are NOT done (else worker would immediately terminate) */
i = pthread_create(&pThis->thrdWorker, NULL, queueWorker, (void*) pThis);
- dbgprintf("Worker thread for queue 0x%lx started with state %d.\n", (unsigned long) pThis, i);
+ dbgprintf("Worker thread for queue 0x%lx, type %d started with state %d.\n",
+ (unsigned long) pThis, (int) qType, i);
finalize_it:
if(iRet == RS_RET_OK) {
diff --git a/queue.h b/queue.h
index b660c44f..d119eab7 100644
--- a/queue.h
+++ b/queue.h
@@ -27,8 +27,8 @@
/* queue types */
typedef enum {
- QUEUETYPE_FIXED_ARRAY,/* a simple queue made out of a fixed (initially malloced) array fast but memoryhog */
- QUEUETYPE_LINKEDLIST,/* linked list used as buffer, lower fixed memory overhead but slower */
+ QUEUETYPE_FIXED_ARRAY = 0,/* a simple queue made out of a fixed (initially malloced) array fast but memoryhog */
+ QUEUETYPE_LINKEDLIST = 1 /* linked list used as buffer, lower fixed memory overhead but slower */
} queueType_t;
/* list member definition for linked list types of queues: */
diff --git a/syslogd.c b/syslogd.c
index 257f1a91..0fe70cbe 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -411,8 +411,10 @@ static int Initialized = 0; /* set when we have initialized ourselves
extern int errno;
-queue_t *pMsgQueue = NULL; /* the main message queue */
-int iMainMsgQueueSize; /* size of the main message queue above */
+/* main message queue and its configuration parameters */
+static queue_t *pMsgQueue = NULL; /* the main message queue */
+static int iMainMsgQueueSize = 10000; /* size of the main message queue above */
+static queueType_t MainMsgQueType = QUEUETYPE_FIXED_ARRAY; /* type of the main message queue above */
/* This structure represents the files that will have log
@@ -506,6 +508,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
pModDir = NULL;
}
iMainMsgQueueSize = 10000;
+ MainMsgQueType = QUEUETYPE_FIXED_ARRAY;
return RS_RET_OK;
}
@@ -3339,8 +3342,7 @@ init(void)
}
/* create message queue */
- //CHKiRet_Hdlr(queueConstruct(&pMsgQueue, QUEUETYPE_FIXED_ARRAY, iMainMsgQueueSize, msgConsumer)) {
- CHKiRet_Hdlr(queueConstruct(&pMsgQueue, QUEUETYPE_LINKEDLIST, iMainMsgQueueSize, msgConsumer)) {
+ CHKiRet_Hdlr(queueConstruct(&pMsgQueue, MainMsgQueType, iMainMsgQueueSize, msgConsumer)) {
/* no queue is fatal, we need to give up in that case... */
fprintf(stderr, "fatal error %d: could not create message queue - rsyslogd can not run!\n", iRet);
exit(1);
@@ -4179,6 +4181,29 @@ static rsRetVal cfline(uchar *line, selector_t **pfCurr)
}
+/* set the main message queue mode
+ * rgerhards, 2008-01-03
+ */
+static rsRetVal setMainMsgQueType(void __attribute__((unused)) *pVal, uchar *pszType)
+{
+ DEFiRet;
+
+ if (!strcasecmp((char *) pszType, "fixedarray")) {
+ MainMsgQueType = QUEUETYPE_FIXED_ARRAY;
+ dbgprintf("main message queue type set to FIXED_ARRAY\n");
+ } else if (!strcasecmp((char *) pszType, "linkedlist")) {
+ MainMsgQueType = QUEUETYPE_LINKEDLIST;
+ dbgprintf("main message queue type set to LINKEDLIST\n");
+ } else {
+ logerrorSz("unknown mainmessagequeuetype parameter: %s", (char *) pszType);
+ iRet = RS_RET_INVALID_PARAMS;
+ }
+ free(pszType); /* no longer needed */
+
+ return iRet;
+}
+
+
/* Decode a symbolic name to a numeric value
*/
int decode(uchar *name, struct code *codetab)
@@ -4441,6 +4466,7 @@ static rsRetVal loadBuildInModules(void)
* This, I think, is the right thing to do. -- rgerhards, 2007-07-31
*/
CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt, NULL, &iMainMsgQueueSize, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuetype", 0, eCmdHdlrGetWord, setMainMsgQueType, NULL, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", 0, eCmdHdlrBinary, NULL, &bReduceRepeatMsgs, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"actionexeconlywhenpreviousissuspended", 0, eCmdHdlrBinary, NULL, &bActExecWhenPrevSusp, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"actionresumeinterval", 0, eCmdHdlrInt, setActionResumeInterval, NULL, NULL));