diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-04-27 17:11:41 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-04-27 17:11:41 +0200 |
commit | 5cd3cdf3c82ef49506124ace13d20c52afd5d44a (patch) | |
tree | 5d510436b780c30757378bbc70b8f8024db38f4b | |
parent | 4f8457ffe3bc0a104a86ac79622844c4206adbbb (diff) | |
download | rsyslog-5cd3cdf3c82ef49506124ace13d20c52afd5d44a.tar.gz rsyslog-5cd3cdf3c82ef49506124ace13d20c52afd5d44a.tar.xz rsyslog-5cd3cdf3c82ef49506124ace13d20c52afd5d44a.zip |
step: config-specific module list used during config processing
-rw-r--r-- | runtime/conf.c | 8 | ||||
-rw-r--r-- | runtime/modules.c | 33 | ||||
-rw-r--r-- | runtime/modules.h | 6 | ||||
-rw-r--r-- | runtime/rsconf.c | 20 | ||||
-rw-r--r-- | tools/syslogd.c | 2 |
5 files changed, 40 insertions, 29 deletions
diff --git a/runtime/conf.c b/runtime/conf.c index 67c1ed81..ea7102a6 100644 --- a/runtime/conf.c +++ b/runtime/conf.c @@ -1105,7 +1105,7 @@ static rsRetVal cflineDoAction(rsconf_t *conf, uchar **p, action_t **ppAction) ASSERT(ppAction != NULL); /* loop through all modules and see if one picks up the line */ - pMod = module.GetNxtType(NULL, eMOD_OUT); + pMod = module.GetNxtCnfType(conf, NULL, eMOD_OUT); /* Note: clang static analyzer reports that pMod mybe == NULL. However, this is * not possible, because we have the built-in output modules which are always * present. Anyhow, we guard this by an assert. -- rgerhards, 2010-12-16 @@ -1144,7 +1144,7 @@ static rsRetVal cflineDoAction(rsconf_t *conf, uchar **p, action_t **ppAction) dbgprintf("error %d parsing config line\n", (int) iRet); break; } - pMod = module.GetNxtType(pMod, eMOD_OUT); + pMod = module.GetNxtCnfType(conf, pMod, eMOD_OUT); } *ppAction = pAction; @@ -1287,7 +1287,7 @@ setActionScope(void) /* now tell each action to start the scope */ pMod = NULL; - while((pMod = module.GetNxtType(pMod, eMOD_OUT)) != NULL) { + while((pMod = module.GetNxtCnfType(loadConf, pMod, eMOD_OUT)) != NULL) { DBGPRINTF("beginning scope on module %s\n", pMod->pszName); pMod->mod.om.newScope(); } @@ -1312,7 +1312,7 @@ unsetActionScope(void) /* now tell each action to restore the scope */ pMod = NULL; - while((pMod = module.GetNxtType(pMod, eMOD_OUT)) != NULL) { + while((pMod = module.GetNxtCnfType(loadConf, pMod, eMOD_OUT)) != NULL) { DBGPRINTF("exiting scope on module %s\n", pMod->pszName); pMod->mod.om.restoreScope(); } diff --git a/runtime/modules.c b/runtime/modules.c index 8cdc9bb1..69c89790 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -335,7 +335,7 @@ addModToGlblList(modInfo_t *pThis) /* Add a module to the config module list for current loadConf */ -static inline rsRetVal +rsRetVal addModToCnfList(modInfo_t *pThis) { cfgmodules_etry_t *pNew; @@ -401,18 +401,31 @@ static modInfo_t *GetNxt(modInfo_t *pThis) /* this function is like GetNxt(), but it returns pointers to - * modules of specific type only. - * rgerhards, 2007-07-24 + * modules of specific type only. Only modules from the provided + * config are returned. Note that processing speed could be improved, + * but this is really not relevant, as config file loading is not really + * something we are concerned about in regard to runtime. */ -static modInfo_t *GetNxtType(modInfo_t *pThis, eModType_t rqtdType) +static modInfo_t *GetNxtCnfType(rsconf_t *cnf, modInfo_t *pThis, eModType_t rqtdType) { - modInfo_t *pMod = pThis; + cfgmodules_etry_t *node; + + if(pThis == NULL) { /* start at beginning of module list */ + node = cnf->modules.root; + } else { /* start at last location - then we need to find the module in the config list */ + for(node = cnf->modules.root ; node != NULL && node->pMod != pThis ; node = node->next) + /*search only, all done in for() */; + if(node != NULL) + node = node->next; /* skip to NEXT element in list */ + } - do { - pMod = GetNxt(pMod); - } while(!(pMod == NULL || pMod->eType == rqtdType)); /* warning: do ... while() */ +dbgprintf("XXXX: entering node, ptr %p: %s\n", node, (node == NULL)? "":modGetName(node->pMod)); + while(node != NULL && node->pMod->eType != rqtdType) { + node = node->next; /* warning: do ... while() */ +dbgprintf("XXXX: in loop, ptr %p: %s\n", node, (node == NULL)? "":modGetName(node->pMod)); + } - return pMod; + return (node == NULL) ? NULL : node->pMod; } @@ -1111,7 +1124,7 @@ CODESTARTobjQueryInterface(module) * of course, also affects the "if" above). */ pIf->GetNxt = GetNxt; - pIf->GetNxtType = GetNxtType; + pIf->GetNxtCnfType = GetNxtCnfType; pIf->GetName = modGetName; pIf->GetStateName = modGetStateName; pIf->PrintList = modPrintList; diff --git a/runtime/modules.h b/runtime/modules.h index 4da8c7a6..37a73ecd 100644 --- a/runtime/modules.h +++ b/runtime/modules.h @@ -159,7 +159,7 @@ struct modInfo_s { /* interfaces */ BEGINinterface(module) /* name must also be changed in ENDinterface macro! */ modInfo_t *(*GetNxt)(modInfo_t *pThis); - modInfo_t *(*GetNxtType)(modInfo_t *pThis, eModType_t rqtdType); + modInfo_t *(*GetNxtCnfType)(rsconf_t *cnf, modInfo_t *pThis, eModType_t rqtdType); uchar *(*GetName)(modInfo_t *pThis); uchar *(*GetStateName)(modInfo_t *pThis); rsRetVal (*Use)(char *srcFile, modInfo_t *pThis); /**< must be called before a module is used (ref counting) */ @@ -172,7 +172,9 @@ BEGINinterface(module) /* name must also be changed in ENDinterface macro! */ ENDinterface(module) #define moduleCURR_IF_VERSION 2 /* increment whenever you change the interface structure! */ /* Changes: - * v2 - added param bCondLoad to Load call - 2011-04-27 + * v2 + * - added param bCondLoad to Load call - 2011-04-27 + * - removed GetNxtType, added GetNxtCnfType - 2011-04-27 */ /* prototypes */ diff --git a/runtime/rsconf.c b/runtime/rsconf.c index bc41d57c..b50b4fb6 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -301,7 +301,7 @@ runInputModules(void) BEGINfunc /* loop through all modules and activate them (brr...) */ - pMod = module.GetNxtType(NULL, eMOD_IN); + pMod = module.GetNxtCnfType(runConf, NULL, eMOD_IN); while(pMod != NULL) { if(pMod->mod.im.bCanRun) { /* activate here */ @@ -309,7 +309,7 @@ runInputModules(void) 0 : 1; thrdCreate(pMod->mod.im.runInput, pMod->mod.im.afterRun, bNeedsCancel); } - pMod = module.GetNxtType(pMod, eMOD_IN); + pMod = module.GetNxtCnfType(runConf, pMod, eMOD_IN); } ENDfunc @@ -317,11 +317,7 @@ runInputModules(void) } -/* 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 - * running. Almost no config option is taken. - * rgerhards, 2007-12-14 +/* Make the input modules check if they are ready to start. */ static rsRetVal startInputModules(void) @@ -330,14 +326,14 @@ startInputModules(void) modInfo_t *pMod; /* loop through all modules and activate them (brr...) */ - pMod = module.GetNxtType(NULL, eMOD_IN); + pMod = module.GetNxtCnfType(runConf, NULL, eMOD_IN); while(pMod != NULL) { 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); + pMod = module.GetNxtCnfType(runConf, pMod, eMOD_IN); } ENDfunc @@ -355,6 +351,8 @@ activate(rsconf_t *cnf) { DEFiRet; + /* at this point, we "switch" over to the running conf */ + runConf = cnf; # if 0 /* currently the DAG is not supported -- code missing! */ /* TODO: re-enable this functionality some time later! */ /* check if we need to generate a config DAG and, if so, do that */ @@ -377,7 +375,6 @@ activate(rsconf_t *cnf) /* finally let the inputs run... */ runInputModules(); - runConf = cnf; dbgprintf("configuration %p activated\n", cnf); finalize_it: @@ -589,6 +586,7 @@ regBuildInModule(rsRetVal (*modInit)(), uchar *name, void *pModHdlr) modInfo_t *pMod; DEFiRet; CHKiRet(module.doModInit(modInit, name, pModHdlr, &pMod)); + addModToCnfList(pMod); finalize_it: RETiRet; } @@ -694,8 +692,6 @@ initLegacyConf(void) CHKiRet(regCfSysLineHdlr((uchar *)"actionresumeinterval", 0, eCmdHdlrInt, setActionResumeInterval, NULL, NULL, eConfObjGlobal)); - //CHKiRet(regCfSysLineHdlr((uchar *)"modload", 0, eCmdHdlrCustomHandler, - //doModLoad, NULL, NULL, eConfObjGlobal)); CHKiRet(regCfSysLineHdlr((uchar *)"modload", 0, eCmdHdlrCustomHandler, conf.doModLoad, NULL, NULL, eConfObjGlobal)); CHKiRet(regCfSysLineHdlr((uchar *)"includeconfig", 0, eCmdHdlrCustomHandler, diff --git a/tools/syslogd.c b/tools/syslogd.c index fc23f058..dcce4d77 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -2176,7 +2176,7 @@ int realMain(int argc, char **argv) "startup with a dirty config.\n"); exit(2); } - iRet = RS_RET_OK; + localRet = RS_RET_OK; } CHKiRet(localRet); |