mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-18 16:50:42 +01:00
step: generalized new config interface for all module types
This commit is contained in:
parent
c0d1334f6e
commit
b056c258d7
@ -94,6 +94,7 @@ void OnReceive(srAPIObj __attribute__((unused)) *pMyAPI, srSLMGObj* pSLMG)
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
BEGINbeginCnfLoad
|
||||
CODESTARTbeginCnfLoad
|
||||
ENDbeginCnfLoad
|
||||
@ -117,6 +118,7 @@ ENDactivateCnf
|
||||
BEGINfreeCnf
|
||||
CODESTARTfreeCnf
|
||||
ENDfreeCnf
|
||||
#endif
|
||||
|
||||
|
||||
BEGINrunInput
|
||||
|
||||
@ -388,6 +388,7 @@ finalize_it:
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* can be used to integrate into new config system */
|
||||
BEGINbeginCnfLoad
|
||||
CODESTARTbeginCnfLoad
|
||||
ENDbeginCnfLoad
|
||||
@ -411,6 +412,7 @@ ENDactivateCnf
|
||||
BEGINfreeCnf
|
||||
CODESTARTfreeCnf
|
||||
ENDfreeCnf
|
||||
#endif
|
||||
|
||||
/* This function is called to gather input.
|
||||
*/
|
||||
|
||||
@ -645,6 +645,7 @@ TCPSessGSSDeinit(void)
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* can be used to integrate into new config system */
|
||||
BEGINbeginCnfLoad
|
||||
CODESTARTbeginCnfLoad
|
||||
ENDbeginCnfLoad
|
||||
@ -668,6 +669,7 @@ ENDactivateCnf
|
||||
BEGINfreeCnf
|
||||
CODESTARTfreeCnf
|
||||
ENDfreeCnf
|
||||
#endif
|
||||
|
||||
/* This function is called to gather input.
|
||||
*/
|
||||
|
||||
@ -148,6 +148,7 @@ ENDmodExit
|
||||
BEGINqueryEtryPt
|
||||
CODESTARTqueryEtryPt
|
||||
CODEqueryEtryPt_STD_IMOD_QUERIES
|
||||
CODEqueryEtryPt_STD_CONF2_QUERIES
|
||||
CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES
|
||||
ENDqueryEtryPt
|
||||
|
||||
|
||||
@ -421,6 +421,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
|
||||
BEGINqueryEtryPt
|
||||
CODESTARTqueryEtryPt
|
||||
CODEqueryEtryPt_STD_IMOD_QUERIES
|
||||
CODEqueryEtryPt_STD_CONF2_QUERIES
|
||||
CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES
|
||||
ENDqueryEtryPt
|
||||
|
||||
|
||||
@ -100,6 +100,7 @@ struct modConfData_s {
|
||||
};
|
||||
|
||||
|
||||
#if 0 /* can be used to integrate into new config system */
|
||||
BEGINbeginCnfLoad
|
||||
CODESTARTbeginCnfLoad
|
||||
ENDbeginCnfLoad
|
||||
@ -123,6 +124,7 @@ ENDactivateCnf
|
||||
BEGINfreeCnf
|
||||
CODESTARTfreeCnf
|
||||
ENDfreeCnf
|
||||
#endif
|
||||
|
||||
|
||||
/* You may add any functions that you feel are useful for your needs. No specific restrictions
|
||||
|
||||
@ -744,6 +744,7 @@ ENDisCompatibleWithFeature
|
||||
BEGINqueryEtryPt
|
||||
CODESTARTqueryEtryPt
|
||||
CODEqueryEtryPt_STD_IMOD_QUERIES
|
||||
CODEqueryEtryPt_STD_CONF2_QUERIES
|
||||
CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES
|
||||
ENDqueryEtryPt
|
||||
|
||||
|
||||
@ -459,7 +459,14 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
|
||||
*pEtryPoint = willRun;\
|
||||
} else if(!strcmp((char*) name, "afterRun")) {\
|
||||
*pEtryPoint = afterRun;\
|
||||
} else if(!strcmp((char*) name, "beginCnfLoad")) {\
|
||||
}
|
||||
|
||||
|
||||
/* the following block is to be added for modules that support the v2
|
||||
* config system.
|
||||
*/
|
||||
#define CODEqueryEtryPt_STD_CONF2_QUERIES \
|
||||
else if(!strcmp((char*) name, "beginCnfLoad")) {\
|
||||
*pEtryPoint = beginCnfLoad;\
|
||||
} else if(!strcmp((char*) name, "endCnfLoad")) {\
|
||||
*pEtryPoint = endCnfLoad;\
|
||||
|
||||
@ -371,8 +371,9 @@ addModToCnfList(modInfo_t *pThis)
|
||||
pNew->next = NULL;
|
||||
pNew->pMod = pThis;
|
||||
|
||||
if(pThis->eType == eMOD_IN) {
|
||||
CHKiRet(pThis->mod.im.beginCnfLoad(&pNew->modCnf, loadConf));
|
||||
dbgprintf("XXXX: beginCnfLoad %p\n", pThis->beginCnfLoad);
|
||||
if(pThis->beginCnfLoad != NULL) {
|
||||
CHKiRet(pThis->beginCnfLoad(&pNew->modCnf, loadConf));
|
||||
}
|
||||
|
||||
if(pLast == NULL) {
|
||||
@ -424,8 +425,10 @@ static cfgmodules_etry_t
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
while(node != NULL && node->pMod->eType != rqtdType) {
|
||||
node = node->next; /* warning: do ... while() */
|
||||
if(rqtdType != eMOD_ANY) { /* if any, we already have the right one! */
|
||||
while(node != NULL && node->pMod->eType != rqtdType) {
|
||||
node = node->next; /* warning: do ... while() */
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
@ -518,14 +521,21 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
|
||||
else if(localRet != RS_RET_OK)
|
||||
ABORT_FINALIZE(localRet);
|
||||
|
||||
/* optional calls for new config system */
|
||||
localRet = (*pNew->modQueryEtryPt)((uchar*)"beginCnfLoad", &pNew->beginCnfLoad);
|
||||
if(localRet == RS_RET_OK) {
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"endCnfLoad", &pNew->endCnfLoad));
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"freeCnf", &pNew->freeCnf));
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"checkCnf", &pNew->checkCnf));
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"activateCnf", &pNew->activateCnf));
|
||||
} else if(localRet == RS_RET_MODULE_ENTRY_POINT_NOT_FOUND) {
|
||||
pNew->beginCnfLoad = NULL; /* flag as non-present */
|
||||
} else {
|
||||
ABORT_FINALIZE(localRet);
|
||||
}
|
||||
/* ... and now the module-specific interfaces */
|
||||
switch(pNew->eType) {
|
||||
case eMOD_IN:
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"beginCnfLoad", &pNew->mod.im.beginCnfLoad));
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"endCnfLoad", &pNew->mod.im.endCnfLoad));
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"freeCnf", &pNew->mod.im.freeCnf));
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"checkCnf", &pNew->mod.im.checkCnf));
|
||||
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"activateCnf", &pNew->mod.im.activateCnf));
|
||||
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));
|
||||
@ -602,6 +612,10 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
|
||||
CHKiRet(strgen.SetModPtr(pStrgen, pNew));
|
||||
CHKiRet(strgen.ConstructFinalize(pStrgen));
|
||||
break;
|
||||
case eMOD_ANY: /* this is mostly to keep the compiler happy! */
|
||||
DBGPRINTF("PROGRAM ERROR: eMOD_ANY set as module type\n");
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
|
||||
pNew->pszName = (uchar*) strdup((char*)name); /* we do not care if strdup() fails, we can accept that */
|
||||
@ -681,12 +695,19 @@ static void modPrintList(void)
|
||||
case eMOD_STRGEN:
|
||||
dbgprintf("strgen");
|
||||
break;
|
||||
case eMOD_ANY: /* this is mostly to keep the compiler happy! */
|
||||
DBGPRINTF("PROGRAM ERROR: eMOD_ANY set as module type\n");
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
dbgprintf(" module.\n");
|
||||
dbgprintf("Entry points:\n");
|
||||
dbgprintf("\tqueryEtryPt: 0x%lx\n", (unsigned long) pMod->modQueryEtryPt);
|
||||
dbgprintf("\tdbgPrintInstInfo: 0x%lx\n", (unsigned long) pMod->dbgPrintInstInfo);
|
||||
dbgprintf("\tfreeInstance: 0x%lx\n", (unsigned long) pMod->freeInstance);
|
||||
dbgprintf("\tbeginCnfLoad: 0x%lx\n", (unsigned long) pMod->beginCnfLoad);
|
||||
dbgprintf("\tendCnfLoad: 0x%lx\n", (unsigned long) pMod->endCnfLoad);
|
||||
dbgprintf("\tfreeCnf: 0x%lx\n", (unsigned long) pMod->freeCnf);
|
||||
switch(pMod->eType) {
|
||||
case eMOD_OUT:
|
||||
dbgprintf("Output Module Entry Points:\n");
|
||||
@ -705,9 +726,6 @@ static void modPrintList(void)
|
||||
break;
|
||||
case eMOD_IN:
|
||||
dbgprintf("Input Module Entry Points\n");
|
||||
dbgprintf("\tbeginCnfLoad: 0x%lx\n", (unsigned long) pMod->mod.im.beginCnfLoad);
|
||||
dbgprintf("\tendCnfLoad: 0x%lx\n", (unsigned long) pMod->mod.im.endCnfLoad);
|
||||
dbgprintf("\tfreeCnf: 0x%lx\n", (unsigned long) pMod->mod.im.freeCnf);
|
||||
dbgprintf("\trunInput: 0x%lx\n", (unsigned long) pMod->mod.im.runInput);
|
||||
dbgprintf("\twillRun: 0x%lx\n", (unsigned long) pMod->mod.im.willRun);
|
||||
dbgprintf("\tafterRun: 0x%lx\n", (unsigned long) pMod->mod.im.afterRun);
|
||||
@ -722,6 +740,8 @@ static void modPrintList(void)
|
||||
dbgprintf("Strgen Module Entry Points\n");
|
||||
dbgprintf("\tstrgen: 0x%lx\n", (unsigned long) pMod->mod.sm.strgen);
|
||||
break;
|
||||
case eMOD_ANY: /* this is mostly to keep the compiler happy! */
|
||||
break;
|
||||
}
|
||||
dbgprintf("\n");
|
||||
pMod = GetNxt(pMod); /* done, go next */
|
||||
|
||||
@ -57,7 +57,8 @@ typedef enum eModType_ {
|
||||
eMOD_OUT = 1, /* output module */
|
||||
eMOD_LIB = 2, /* library module */
|
||||
eMOD_PARSER = 3,/* parser module */
|
||||
eMOD_STRGEN = 4 /* strgen module */
|
||||
eMOD_STRGEN = 4,/* strgen module */
|
||||
eMOD_ANY = 5 /* meta-name for "any type of module" -- to be used in function calls */
|
||||
} eModType_t;
|
||||
|
||||
|
||||
@ -110,17 +111,19 @@ struct modInfo_s {
|
||||
rsRetVal (*modExit)(void); /* called before termination or module unload */
|
||||
rsRetVal (*modGetID)(void **); /* get its unique ID from module */
|
||||
rsRetVal (*doHUP)(void *); /* non-restart type HUP handler */
|
||||
/* v2 config system specific */
|
||||
rsRetVal (*beginCnfLoad)(void*newCnf, rsconf_t *pConf);
|
||||
rsRetVal (*endCnfLoad)(void*Cnf);
|
||||
rsRetVal (*checkCnf)(void*Cnf);
|
||||
rsRetVal (*activateCnf)(void*Cnf); /* make provided config the running conf */
|
||||
rsRetVal (*freeCnf)(void*Cnf);
|
||||
/* end v2 config system specific */
|
||||
/* below: create an instance of this module. Most importantly the module
|
||||
* can allocate instance memory in this call.
|
||||
*/
|
||||
rsRetVal (*createInstance)();
|
||||
union {
|
||||
struct {/* data for input modules */
|
||||
rsRetVal (*beginCnfLoad)(void*newCnf, rsconf_t *pConf);
|
||||
rsRetVal (*endCnfLoad)(void*Cnf);
|
||||
rsRetVal (*checkCnf)(void*Cnf);
|
||||
rsRetVal (*activateCnf)(void*Cnf); /* make provided config the running conf */
|
||||
rsRetVal (*freeCnf)(void*Cnf);
|
||||
/* TODO: remove? */rsRetVal (*willRun)(void); /* check if the current config will be able to run*/
|
||||
rsRetVal (*runInput)(thrdInfo_t*); /* function to gather input and submit to queue */
|
||||
rsRetVal (*afterRun)(thrdInfo_t*); /* function to gather input and submit to queue */
|
||||
|
||||
@ -301,10 +301,11 @@ tellInputsConfigLoadDone(void)
|
||||
cfgmodules_etry_t *node;
|
||||
|
||||
BEGINfunc
|
||||
DBGPRINTF("telling inputs that config load for %p is done\n", loadConf);
|
||||
node = module.GetNxtCnfType(loadConf, NULL, eMOD_IN);
|
||||
DBGPRINTF("telling modules that config load for %p is done\n", loadConf);
|
||||
node = module.GetNxtCnfType(loadConf, NULL, eMOD_ANY);
|
||||
while(node != NULL) {
|
||||
node->pMod->mod.im.endCnfLoad(node->modCnf);
|
||||
if(node->pMod->beginCnfLoad != NULL)
|
||||
node->pMod->endCnfLoad(node->modCnf);
|
||||
node = module.GetNxtCnfType(runConf, node, eMOD_IN);
|
||||
}
|
||||
|
||||
@ -321,16 +322,18 @@ tellInputsCheckConfig(void)
|
||||
rsRetVal localRet;
|
||||
|
||||
BEGINfunc
|
||||
DBGPRINTF("telling inputs to check config %p\n", loadConf);
|
||||
node = module.GetNxtCnfType(loadConf, NULL, eMOD_IN);
|
||||
DBGPRINTF("telling modules to check config %p\n", loadConf);
|
||||
node = module.GetNxtCnfType(loadConf, NULL, eMOD_ANY);
|
||||
while(node != NULL) {
|
||||
localRet = node->pMod->mod.im.checkCnf(node->modCnf);
|
||||
DBGPRINTF("module %s tells us config can %sbe activated\n",
|
||||
node->pMod->pszName, (localRet == RS_RET_OK) ? "" : "NOT ");
|
||||
if(localRet == RS_RET_OK) {
|
||||
node->canActivate = 1;
|
||||
} else {
|
||||
node->canActivate = 0;
|
||||
if(node->pMod->beginCnfLoad != NULL) {
|
||||
localRet = node->pMod->checkCnf(node->modCnf);
|
||||
DBGPRINTF("module %s tells us config can %sbe activated\n",
|
||||
node->pMod->pszName, (localRet == RS_RET_OK) ? "" : "NOT ");
|
||||
if(localRet == RS_RET_OK) {
|
||||
node->canActivate = 1;
|
||||
} else {
|
||||
node->canActivate = 0;
|
||||
}
|
||||
}
|
||||
node = module.GetNxtCnfType(runConf, node, eMOD_IN);
|
||||
}
|
||||
@ -348,13 +351,13 @@ tellInputsActivateConfig(void)
|
||||
rsRetVal localRet;
|
||||
|
||||
BEGINfunc
|
||||
DBGPRINTF("telling inputs to activate config %p\n", runConf);
|
||||
node = module.GetNxtCnfType(runConf, NULL, eMOD_IN);
|
||||
DBGPRINTF("telling modules to activate config %p\n", runConf);
|
||||
node = module.GetNxtCnfType(runConf, NULL, eMOD_ANY);
|
||||
while(node != NULL) {
|
||||
if(node->canActivate) {
|
||||
if(node->pMod->beginCnfLoad != NULL && node->canActivate) {
|
||||
DBGPRINTF("activating config %p for module %s\n",
|
||||
runConf, node->pMod->pszName);
|
||||
localRet = node->pMod->mod.im.activateCnf(node->modCnf);
|
||||
localRet = node->pMod->activateCnf(node->modCnf);
|
||||
if(localRet != RS_RET_OK) {
|
||||
errmsg.LogError(0, localRet, "activation of module %s failed",
|
||||
node->pMod->pszName);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user