From 549c0cccd44dc36a6ba8c480fa65bcaad6cb20ec Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 7 Mar 2008 16:10:58 +0000 Subject: extracted regexp functionality to its own dynamically loadable module --- obj.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'obj.c') diff --git a/obj.c b/obj.c index 2bbbe4bb..5a144727 100644 --- a/obj.c +++ b/obj.c @@ -1052,7 +1052,7 @@ RUNLOG_VAR("%p", errmsg.LogError); * rgerhards, 2008-02-29 */ static rsRetVal -UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *ppIf) +UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf) { DEFiRet; cstr_t *pStr = NULL; @@ -1061,13 +1061,29 @@ UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *ppIf) CHKiRet(rsCStrConstructFromszStr(&pStr, pObjName)); iRet = FindObjInfo(pStr, &pObjInfo); - dbgprintf("source file %s requests object '%s'\n", srcFile, pObjName); + dbgprintf("source file %s requests object '%s', ifIsLoaded %d\n", srcFile, pObjName, pIf->ifIsLoaded); + + if(pIf->ifIsLoaded == 1) { + ABORT_FINALIZE(RS_RET_OK); /* we are already set */ + } + if(pIf->ifIsLoaded == 2) { + ABORT_FINALIZE(RS_RET_LOAD_ERROR); /* we had a load error and can not continue */ + } + + /* we must be careful that we do not enter in infinite loop if an error occurs during + * loading a module. ModLoad emits an error message in such cases and that potentially + * can trigger the same code here. So we initially set the module state to "load error" + * and set it to "fully initialized" when the load succeeded. It's a bit hackish, but + * looks like a good solution. -- rgerhards, 2008-03-07 + */ + pIf->ifIsLoaded = 2; if(iRet == RS_RET_NOT_FOUND) { /* in this case, we need to see if we can dynamically load the object */ if(pObjFile == NULL) { FINALIZE; /* no chance, we have lost... */ } else { CHKiRet(module.Load(pObjFile)); + pIf->ifIsLoaded = 1; /* all went well! */ /* NOW, we must find it or we have a problem... */ CHKiRet(FindObjInfo(pStr, &pObjInfo)); } @@ -1075,7 +1091,7 @@ UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *ppIf) FINALIZE; /* give up */ } - pObjInfo->QueryIF(ppIf); + pObjInfo->QueryIF(pIf); finalize_it: if(pStr != NULL) -- cgit v1.2.3