summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-08-07 13:46:37 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-08-07 13:46:37 +0000
commit634540541cc44580086c21a419c79cb0433d191e (patch)
tree88e774f8bc04183078c1ba2315fbd5a7733d982f
parent1cd509518956cd0ad3cfa4c279643a098bc0be2c (diff)
downloadrsyslog-634540541cc44580086c21a419c79cb0433d191e.tar.gz
rsyslog-634540541cc44580086c21a419c79cb0433d191e.tar.xz
rsyslog-634540541cc44580086c21a419c79cb0433d191e.zip
add config directive $MainMsgQueueSize, which now allows to configure the
queue size dynamically
-rw-r--r--ChangeLog2
-rw-r--r--syslogd.c28
2 files changed, 23 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index bd6f4390..386843c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@ Version 1.18.1 (rgerhards), 2007-08-??
- applied patch from Michel Samia to fix compilation when the pthreads
feature is disabled
- some code cleanup (moved action object to its own file set)
+- add config directive $MainMsgQueueSize, which now allows to configure the
+ queue size dynamically
---------------------------------------------------------------------------
Version 1.18.0 (rgerhards), 2007-08-03
- rsyslog now supports fallback actions when an action did not work. This
diff --git a/syslogd.c b/syslogd.c
index 1b0599de..77630246 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -407,15 +407,15 @@ static rsCStrObj *pDfltProgNameCmp;
/* this is the first approach to a queue, this time with static
* memory.
*/
-#define QUEUESIZE 10000
typedef struct {
- void* buf[QUEUESIZE];
+ void** pbuf;
long head, tail;
int full, empty;
pthread_mutex_t *mut;
pthread_cond_t *notFull, *notEmpty;
} msgQueue;
+int iMainMsgQueueSize;
int bRunningMultithreaded = 0; /* Is this program running in multithreaded mode? */
msgQueue *pMsgQueue = NULL;
static pthread_t thrdWorker;
@@ -641,6 +641,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
bDebugPrintModuleList = 1;
bEscapeCCOnRcv = 1; /* default is to escape control characters */
bReduceRepeatMsgs = (logEveryMsg == 1) ? 0 : 1;
+ iMainMsgQueueSize = 10000;
return RS_RET_OK;
}
@@ -2604,8 +2605,12 @@ static msgQueue *queueInit (void)
{
msgQueue *q;
- q = (msgQueue *)malloc (sizeof (msgQueue));
+ q = (msgQueue *)malloc(sizeof(msgQueue));
if (q == NULL) return (NULL);
+ if((q->pbuf = malloc(sizeof(void *) * iMainMsgQueueSize)) == NULL) {
+ free(q);
+ return NULL;
+ }
q->empty = 1;
q->full = 0;
@@ -2629,14 +2634,15 @@ static void queueDelete (msgQueue *q)
free (q->notFull);
pthread_cond_destroy (q->notEmpty);
free (q->notEmpty);
+ free(q->pbuf);
free (q);
}
static void queueAdd (msgQueue *q, void* in)
{
- q->buf[q->tail] = in;
+ q->pbuf[q->tail] = in;
q->tail++;
- if (q->tail == QUEUESIZE)
+ if (q->tail == iMainMsgQueueSize)
q->tail = 0;
if (q->tail == q->head)
q->full = 1;
@@ -2647,10 +2653,10 @@ static void queueAdd (msgQueue *q, void* in)
static void queueDel (msgQueue *q, msg_t **out)
{
- *out = (msg_t*) q->buf[q->head];
+ *out = (msg_t*) q->pbuf[q->head];
q->head++;
- if (q->head == QUEUESIZE)
+ if (q->head == iMainMsgQueueSize)
q->head = 0;
if (q->head == q->tail)
q->empty = 1;
@@ -4011,9 +4017,14 @@ static void dbgPrintInitInfo(void)
printf("Control characters are %sreplaced upon reception.\n",
bEscapeCCOnRcv? "" : "not ");
+
if(bEscapeCCOnRcv)
printf("Control character escape sequence prefix is '%c'.\n",
cCCEscapeChar);
+
+#ifdef USE_PTHREADS
+ printf("Main queue size %d messages.\n", iMainMsgQueueSize);
+#endif
}
@@ -5766,6 +5777,9 @@ static rsRetVal loadBuildInModules(void)
* is that rsyslog will terminate if we can not register our built-in config commands.
* This, I think, is the right thing to do. -- rgerhards, 2007-07-31
*/
+#ifdef USE_PTHREADS
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt, NULL, &iMainMsgQueueSize));
+#endif
CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", 0, eCmdHdlrBinary, NULL, &bReduceRepeatMsgs));
CHKiRet(regCfSysLineHdlr((uchar *)"actionexeconlywhenpreviousissuspended", 0, eCmdHdlrBinary, NULL, &bActExecWhenPrevSusp));
CHKiRet(regCfSysLineHdlr((uchar *)"controlcharacterescapeprefix", 0, eCmdHdlrGetChar, NULL, &cCCEscapeChar));