summaryrefslogtreecommitdiff
path: root/modules.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2008-03-29 12:14:28 +0100
committerMichael Biebl <biebl@debian.org>2008-03-29 12:14:28 +0100
commit1ff3d60958bd7f477cf3dfaf8b20a4637109c18f (patch)
tree723d3d56a0e1305aafb8b41c0a32a05ca5b21179 /modules.c
parent42b56a64a53e45546f8cca2084911c3495e7fbb6 (diff)
downloadrsyslog-1ff3d60958bd7f477cf3dfaf8b20a4637109c18f.tar.gz
Imported Debian patch 1.19.1-1debian/1.19.1-1
Diffstat (limited to 'modules.c')
-rw-r--r--modules.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/modules.c b/modules.c
index 5ecceec..b17f798 100644
--- a/modules.c
+++ b/modules.c
@@ -69,6 +69,8 @@ static void moduleDestruct(modInfo_t *pThis)
{
if(pThis->pszName != NULL)
free(pThis->pszName);
+ if(pThis->pModHdlr != NULL)
+ dlclose(pThis->pModHdlr);
free(pThis);
}
@@ -192,7 +194,7 @@ finalize_it:
/* Add an already-loaded module to the module linked list. This function does
* everything needed to fully initialize the module.
*/
-rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)()), uchar *name)
+rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)()), uchar *name, void *pModHdlr)
{
DEFiRet;
modInfo_t *pNew;
@@ -261,8 +263,13 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)())
}
pNew->pszName = (uchar*) strdup((char*)name); /* we do not care if strdup() fails, we can accept that */
+ pNew->pModHdlr = pModHdlr;
pNew->eType = eMOD_OUT; /* TODO: take this from module */
- pNew->eLinkType = eMOD_LINK_STATIC; /* TODO: take this from module */
+ /* TODO: take this from module */
+ if(pModHdlr == NULL)
+ pNew->eLinkType = eMOD_LINK_STATIC;
+ else
+ pNew->eLinkType = eMOD_LINK_DYNAMIC_LOADED;
/* we initialized the structure, now let's add it to the linked list of modules */
addModToList(pNew);
@@ -329,6 +336,31 @@ rsRetVal modUnloadAndDestructAll(void)
return iRet;
}
+
+
+rsRetVal modUnloadAndDestructDynamic(void)
+{
+ DEFiRet;
+ modInfo_t *pMod;
+ modInfo_t *pModPrev;
+
+ pLoadedModulesLast = NULL;
+
+ pMod = modGetNxt(NULL);
+ while(pMod != NULL) {
+ pModPrev = pMod;
+ pMod = modGetNxt(pModPrev); /* get next */
+ /* now we can destroy the previous module */
+ if(pModPrev->eLinkType != eMOD_LINK_STATIC) {
+ dbgprintf("Unloading module %s\n", modGetName(pModPrev));
+ moduleDestruct(pModPrev);
+ } else {
+ pLoadedModulesLast = pModPrev;
+ }
+ }
+
+ return iRet;
+}
/*
* vi:set ai:
*/