summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/modules.c1
-rw-r--r--runtime/modules.h1
-rw-r--r--tools/syslogd.c46
3 files changed, 39 insertions, 9 deletions
diff --git a/runtime/modules.c b/runtime/modules.c
index 32ae659f..bd201252 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -399,6 +399,7 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"runInput", &pNew->mod.im.runInput));
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"willRun", &pNew->mod.im.willRun));
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"afterRun", &pNew->mod.im.afterRun));
+ pNew->mod.im.bCanRun = 0;
break;
case eMOD_OUT:
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"freeInstance", &pNew->freeInstance));
diff --git a/runtime/modules.h b/runtime/modules.h
index 372529ee..4d874019 100644
--- a/runtime/modules.h
+++ b/runtime/modules.h
@@ -106,6 +106,7 @@ typedef struct modInfo_s {
rsRetVal (*runInput)(thrdInfo_t*); /* function to gather input and submit to queue */
rsRetVal (*willRun)(void); /* function to gather input and submit to queue */
rsRetVal (*afterRun)(thrdInfo_t*); /* function to gather input and submit to queue */
+ int bCanRun; /* cached value of whether willRun() succeeded */
} im;
struct {/* data for output modules */
/* below: perform the configured action
diff --git a/tools/syslogd.c b/tools/syslogd.c
index f6f4b469..6ccacf5f 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -2081,6 +2081,29 @@ static void dbgPrintInitInfo(void)
}
+/* Actually run the input modules. This happens after privileges are dropped,
+ * if that is requested.
+ */
+static rsRetVal
+runInputModules(void)
+{
+ modInfo_t *pMod;
+
+ /* loop through all modules and activate them (brr...) */
+ pMod = module.GetNxtType(NULL, eMOD_IN);
+ while(pMod != NULL) {
+ if(pMod->mod.im.bCanRun) {
+ /* activate here */
+ thrdCreate(pMod->mod.im.runInput, pMod->mod.im.afterRun);
+ }
+ pMod = module.GetNxtType(pMod, eMOD_IN);
+ }
+
+ ENDfunc
+ return RS_RET_OK; /* intentional: we do not care about module errors */
+}
+
+
/* Start the input modules. This function will probably undergo big changes
* while we implement the input module interface. For now, it does the most
* important thing to get at least my poor initial input modules up and
@@ -2088,7 +2111,7 @@ static void dbgPrintInitInfo(void)
* rgerhards, 2007-12-14
*/
static rsRetVal
-startInputModules(void)
+startInputModules(int bRunInputModules)
{
DEFiRet;
modInfo_t *pMod;
@@ -2096,15 +2119,18 @@ startInputModules(void)
/* loop through all modules and activate them (brr...) */
pMod = module.GetNxtType(NULL, eMOD_IN);
while(pMod != NULL) {
- if((iRet = pMod->mod.im.willRun()) == RS_RET_OK) {
- /* activate here */
- thrdCreate(pMod->mod.im.runInput, pMod->mod.im.afterRun);
- } else {
+ iRet = pMod->mod.im.willRun();
+ pMod->mod.im.bCanRun = (iRet == RS_RET_OK);
+ if(!pMod->mod.im.bCanRun) {
DBGPRINTF("module %lx will not run, iRet %d\n", (unsigned long) pMod, iRet);
}
pMod = module.GetNxtType(pMod, eMOD_IN);
}
+ if (bRunInputModules) {
+ runInputModules();
+ }
+
ENDfunc
return RS_RET_OK; /* intentional: we do not care about module errors */
}
@@ -2116,7 +2142,7 @@ startInputModules(void)
* else happens. -- rgerhards, 2008-07-28
*/
static rsRetVal
-init(void)
+init(int bRunInputModules)
{
rsRetVal localRet;
int iNbrActions;
@@ -2321,7 +2347,7 @@ init(void)
* shuffled to down here once we have everything in input modules.
* rgerhards, 2007-12-14
*/
- startInputModules();
+ startInputModules(bRunInputModules);
if(Debug) {
dbgPrintInitInfo();
@@ -2492,7 +2518,7 @@ doHUP(void)
if(glbl.GetHUPisRestart()) {
DBGPRINTF("Received SIGHUP, configured to be restart, reloading rsyslogd.\n");
- init(); /* main queue is stopped as part of init() */
+ init(1); /* main queue is stopped as part of init() */
} else {
DBGPRINTF("Received SIGHUP, configured to be a non-restart type of HUP - notifying actions.\n");
ruleset.IterateAllActions(doHUPActions, NULL);
@@ -2750,6 +2776,8 @@ static rsRetVal mainThread()
pTmp = template_StdPgSQLFmt;
tplLastStaticInit(tplAddLine(" StdPgSQLFmt", &pTmp));
+ CHKiRet(init(0));
+
if(Debug && debugging_on) {
DBGPRINTF("Debugging enabled, SIGUSR1 to turn off debugging.\n");
}
@@ -2777,7 +2805,7 @@ static rsRetVal mainThread()
}
- CHKiRet(init());
+ runInputModules();
/* END OF INTIALIZATION
* ... but keep in mind that we might do a restart and thus init() might