diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-11-21 10:09:02 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-11-21 10:09:02 +0000 |
commit | 214c7bd7f8552f0a07a15373b4a222da6e9e6ba6 (patch) | |
tree | c27d4e7d17f3b85f3a75c4a4b1e1df7fd523a00b /modules.c | |
parent | 96b390934051e8b0de71ccf71538e8ae3319f00d (diff) | |
download | rsyslog-214c7bd7f8552f0a07a15373b4a222da6e9e6ba6.tar.gz rsyslog-214c7bd7f8552f0a07a15373b4a222da6e9e6ba6.tar.xz rsyslog-214c7bd7f8552f0a07a15373b4a222da6e9e6ba6.zip |
added new modExit() entry point to loadable module interface
Diffstat (limited to 'modules.c')
-rw-r--r-- | modules.c | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -42,7 +42,7 @@ #include "modules.h" static modInfo_t *pLoadedModules = NULL; /* list of currently-loaded modules */ -static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */ +static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */ static int bCfsyslineInitialized = 0; @@ -64,8 +64,9 @@ static rsRetVal moduleConstruct(modInfo_t **pThis) } -/* Destructs a module objects. The object must not be linked to the - * linked list of modules. +/* Destructs a module object. The object must not be linked to the + * linked list of modules. Please note that all other dependencies on this + * modules must have been removed before (e.g. CfSysLineHandlers!) */ static void moduleDestruct(modInfo_t *pThis) { @@ -172,8 +173,13 @@ modInfo_t *omodGetNxt(modInfo_t *pThis) * (builtin) module, nothing happens. * The module handle is invalid after this function call and * MUST NOT be used any more. - * This is currently a dummy, to be filled when we have a plug-in interface - * rgerhards, 2007-08-09 + * This is currently a dummy, to be filled when we have a plug-in + * interface - rgerhards, 2007-08-09 + * rgerhards, 2007-11-21: + * When this function is called, all instance-data must already have + * been destroyed. In the case of output modules, this happens when the + * rule set is being destroyed. When we implement other module types, we + * need to think how we handle it there (and if we have any instance data). */ static rsRetVal modUnload(modInfo_t *pThis) { @@ -186,6 +192,11 @@ static rsRetVal modUnload(modInfo_t *pThis) } /* TODO: implement code */ + /* There is a bunch of things we need to do: + * - unregister this modules config handler + * - unload the module itself + * - think about the instances freeInstance() + */ ABORT_FINALIZE(RS_RET_NOT_IMPLEMENTED); finalize_it: @@ -263,6 +274,10 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)()) moduleDestruct(pNew); return iRet; } + if((iRet = (*pNew->modQueryEtryPt)((uchar*)"modExit", &pNew->modExit)) != RS_RET_OK) { + moduleDestruct(pNew); + return iRet; + } pNew->pszName = (uchar*) strdup((char*)name); /* we do not care if strdup() fails, we can accept that */ pNew->pModHdlr = pModHdlr; @@ -355,6 +370,7 @@ rsRetVal modUnloadAndDestructDynamic(void) /* now we can destroy the previous module */ if(pModPrev->eLinkType != eMOD_LINK_STATIC) { dbgprintf("Unloading module %s\n", modGetName(pModPrev)); + modUnload(pModPrev); moduleDestruct(pModPrev); } else { pLoadedModulesLast = pModPrev; |