summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-11 10:11:55 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-11 10:11:55 +0000
commite095d1ab45b205b4849151b15592c2824f04373a (patch)
tree73fec9662d199fece800817138c2f87505ee7499
parentc9430404dbf38d5c7fdbbb8aebc78fce38c0906c (diff)
downloadrsyslog-e095d1ab45b205b4849151b15592c2824f04373a.tar.gz
rsyslog-e095d1ab45b205b4849151b15592c2824f04373a.tar.xz
rsyslog-e095d1ab45b205b4849151b15592c2824f04373a.zip
added $MainMsgQueueImmediateShutdown config directive
-rw-r--r--ChangeLog1
-rw-r--r--doc/rsyslog_conf.html1
-rw-r--r--queue.c13
-rw-r--r--queue.h1
-rw-r--r--syslogd.c13
5 files changed, 16 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 92987c3c..6058b70f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
Version 3.10.2 (rgerhards), 2008-01-1?
- fixed a bug that caused a segfault on startup when no $WorkDir directive
was specified in rsyslog.conf
+- added $MainMsgQueueImmediateShutdown config directive
---------------------------------------------------------------------------
Version 3.10.1 (rgerhards), 2008-01-10
- implemented the "disk" queue mode. However, it currently is of very
diff --git a/doc/rsyslog_conf.html b/doc/rsyslog_conf.html
index bfd2141c..073d9697 100644
--- a/doc/rsyslog_conf.html
+++ b/doc/rsyslog_conf.html
@@ -60,6 +60,7 @@ development and quite unstable...). So you have been warned ;)</p>
-2 option</li>
<li>$klogSymbolsTwice (imklog) [on/<b>off</b>] -- former klogd -s option</li>
<li>$MainMsgQueueFileName &lt;name&gt;</li>
+ <li>$MainMsgQueueImmediateShutdown [on/<b>off</b>]</li>
<li><a href="rsconf1_mainmsgqueuesize.html">$MainMsgQueueSize</a></li>
<li>$MainMsgQueueMaxFileSize &lt;size_nbr&gt;, default 1m</li>
<li>$MainMsgQueueType [<b>FixedArray</b>/LinkedList/Direct/Disk]</li>
diff --git a/queue.c b/queue.c
index bd8f9223..b582fb13 100644
--- a/queue.c
+++ b/queue.c
@@ -345,7 +345,6 @@ static rsRetVal queueShutdownWorkers(queue_t *pThis)
int i;
qWrkCmd_t tShutdownCmd;
-pThis->bImmediateShutdown = 1; /*testing */
assert(pThis != NULL);
/* select shutdown mode */
@@ -415,7 +414,6 @@ queueWorker(void *arg)
/* now we have our identity, on to real processing */
while(pThis->pWrkThrds[iMyThrdIndx].tCurrCmd == eWRKTHRDCMD_RUN
|| (pThis->pWrkThrds[iMyThrdIndx].tCurrCmd == eWRKTHRDCMD_SHUTDOWN && pThis->iQueueSize > 0)) {
-dbgprintf("worker %d runs, cmd %d\n", iMyThrdIndx, pThis->pWrkThrds[iMyThrdIndx].tCurrCmd);
pthread_mutex_lock(pThis->mut);
while (pThis->iQueueSize == 0 && pThis->pWrkThrds[iMyThrdIndx].tCurrCmd == eWRKTHRDCMD_RUN) {
dbgprintf("Queue 0x%lx/w%d: queue EMPTY, waiting for next message.\n",
@@ -492,16 +490,13 @@ rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iWorkerThreads,
assert(pConsumer != NULL);
assert(iWorkerThreads >= 0);
-dbgprintf("queueConstruct 0\n");
if((pThis = (queue_t *)calloc(1, sizeof(queue_t))) == NULL) {
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
-dbgprintf("queueConstruct 0a\n");
/* we have an object, so let's fill the properties */
if((pThis->pszSpoolDir = (uchar*) strdup((char*)glblGetWorkDir())) == NULL)
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
-dbgprintf("queueConstruct 1\n");
pThis->lenSpoolDir = strlen((char*)pThis->pszSpoolDir);
pThis->iMaxFileSize = 1024 * 1024; /* default is 1 MiB */
@@ -519,7 +514,6 @@ dbgprintf("queueConstruct 1\n");
pThis->pszFilePrefix = NULL;
pThis->qType = qType;
-dbgprintf("queueConstruct 2\n");
/* set type-specific handlers and other very type-specific things (we can not totally hide it...) */
switch(qType) {
case QUEUETYPE_FIXED_ARRAY:
@@ -550,14 +544,11 @@ dbgprintf("queueConstruct 2\n");
break;
}
-dbgprintf("queueConstruct 3\n");
/* call type-specific constructor */
CHKiRet(pThis->qConstruct(pThis));
finalize_it:
-dbgprintf("queueConstruct 4\n");
OBJCONSTRUCT_CHECK_SUCCESS_AND_CLEANUP
-dbgprintf("queueConstruct 5\n");
return iRet;
}
@@ -718,6 +709,10 @@ finalize_it:
return iRet;
}
+
+/* some simple object access methods */
+DEFpropSetMeth(queue, bImmediateShutdown, int);
+
/*
* vi:set ai:
*/
diff --git a/queue.h b/queue.h
index 07621972..56a9daaa 100644
--- a/queue.h
+++ b/queue.h
@@ -127,5 +127,6 @@ rsRetVal queueSetMaxFileSize(queue_t *pThis, size_t iMaxFileSize);
rsRetVal queueSetFilePrefix(queue_t *pThis, uchar *pszPrefix, size_t iLenPrefix);
rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iWorkerThreads,
int iMaxQueueSize, rsRetVal (*pConsumer)(void*));
+PROTOTYPEpropSetMeth(queue, bImmediateShutdown, int);
#endif /* #ifndef QUEUE_H_INCLUDED */
diff --git a/syslogd.c b/syslogd.c
index 9c39f459..db31bf9a 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -381,8 +381,6 @@ static int logEveryMsg = 0;/* no repeat message processing - read-only after st
* 1 - do NOT suppress duplicate messages
*/
uchar *pszWorkDir = NULL;/* name of rsyslog's spool directory (without trailing slash) */
-uchar *pszMainMsgQFName = NULL;/* prefix for the main message queue file */
-size_t iMainMsgQueMaxFileSize = 1024*1024;
/* end global config file state variables */
static unsigned int Forwarding = 0;
@@ -420,6 +418,9 @@ static queue_t *pMsgQueue = NULL; /* the main message queue */
static int iMainMsgQueueSize = 10000; /* size of the main message queue above */
static int iMainMsgQueueNumWorkers = 1; /* number of worker threads for the mm queue above */
static queueType_t MainMsgQueType = QUEUETYPE_FIXED_ARRAY; /* type of the main message queue above */
+static uchar *pszMainMsgQFName = NULL; /* prefix for the main message queue file */
+static size_t iMainMsgQueMaxFileSize = 1024*1024;
+static int bMainMsgQImmediateShutdown = 0; /* shut down the queue immediately? */
/* This structure represents the files that will have log
@@ -523,6 +524,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
iMainMsgQueueSize = 10000;
iMainMsgQueMaxFileSize = 1024 * 1024;
iMainMsgQueueNumWorkers = 1;
+ bMainMsgQImmediateShutdown = 0;
MainMsgQueType = QUEUETYPE_FIXED_ARRAY;
return RS_RET_OK;
@@ -3136,8 +3138,9 @@ static void dbgPrintInitInfo(void)
cCCEscapeChar);
dbgprintf("Main queue size %d messages.\n", iMainMsgQueueSize);
- dbgprintf("Main queue worker threads: %d\n", iMainMsgQueueNumWorkers);
- dbgprintf("Spool Directory: '%s'.\n", pszWorkDir);
+ dbgprintf("Main queue worker threads: %d, ImmediateShutdown: %d\n",
+ iMainMsgQueueNumWorkers, bMainMsgQImmediateShutdown);
+ dbgprintf("Work Directory: '%s'.\n", pszWorkDir);
}
@@ -3391,6 +3394,7 @@ init(void)
logerrorInt("Invalid " #directive ", error %d. Ignored, running with default setting", iRet); \
}
+ setQPROP(queueSetbImmediateShutdown, "$MainMsgQueueImmediateShutdown", bMainMsgQImmediateShutdown);
setQPROP(queueSetMaxFileSize, "$MainMsgQueueFileSize", iMainMsgQueMaxFileSize);
setQPROPstr(queueSetFilePrefix, "$MainMsgQueueFileName",
(pszMainMsgQFName == NULL ? (uchar*) "mainq" : pszMainMsgQFName));
@@ -4553,6 +4557,7 @@ static rsRetVal loadBuildInModules(void)
CHKiRet(regCfSysLineHdlr((uchar *)"workdirectory", 0, eCmdHdlrGetWord, NULL, &pszWorkDir, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuefilename", 0, eCmdHdlrGetWord, NULL, &pszMainMsgQFName, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt, NULL, &iMainMsgQueueSize, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueueimmediateshutdown", 0, eCmdHdlrBinary, NULL, &bMainMsgQImmediateShutdown, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuetype", 0, eCmdHdlrGetWord, setMainMsgQueType, NULL, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueueworkerthreads", 0, eCmdHdlrInt, NULL, &iMainMsgQueueNumWorkers, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuemaxfilesize", 0, eCmdHdlrSize, NULL, &iMainMsgQueMaxFileSize, NULL));