summaryrefslogtreecommitdiffstats
path: root/modules.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-18 10:39:03 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-18 10:39:03 +0000
commitccc701b8cbd96ffd26c9957b7654120151e9a90e (patch)
tree5f912dedfaf68bcd4e338b23b0fc6d953eb1bde0 /modules.c
parentd8770fdf74090b4f2f0e625a25660917341c1c5b (diff)
downloadrsyslog-ccc701b8cbd96ffd26c9957b7654120151e9a90e.tar.gz
rsyslog-ccc701b8cbd96ffd26c9957b7654120151e9a90e.tar.xz
rsyslog-ccc701b8cbd96ffd26c9957b7654120151e9a90e.zip
bugfix: rsyslogd aborted on sigup - thanks to varmojfekoj for the patch
Diffstat (limited to 'modules.c')
-rw-r--r--modules.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/modules.c b/modules.c
index 0d412b40..cfbe20ac 100644
--- a/modules.c
+++ b/modules.c
@@ -451,9 +451,14 @@ static void modPrintList(void)
* rgerhards, 2008-02-26
*/
static rsRetVal
-modUnlinkAndDestroy(modInfo_t *pThis)
+modUnlinkAndDestroy(modInfo_t **ppThis)
{
DEFiRet;
+ modInfo_t *pThis;
+
+ assert(ppThis != NULL);
+ pThis = *ppThis;
+ assert(pThis != NULL);
/* first check if we are permitted to unload */
if(pThis->eType == eMOD_LIB) {
@@ -476,7 +481,7 @@ modUnlinkAndDestroy(modInfo_t *pThis)
}
if(pThis->pNext == NULL) {
- pLoadedModulesLast = NULL;
+ pLoadedModulesLast = pThis->pPrev;
} else {
pThis->pNext->pPrev = pThis->pPrev;
}
@@ -484,6 +489,8 @@ modUnlinkAndDestroy(modInfo_t *pThis)
/* finally, we are ready for the module to go away... */
dbgprintf("Unloading module %s\n", modGetName(pThis));
CHKiRet(modPrepareUnload(pThis));
+ *ppThis = pThis->pNext;
+
moduleDestruct(pThis);
finalize_it:
@@ -500,15 +507,16 @@ static rsRetVal
modUnloadAndDestructAll(eModLinkType_t modLinkTypesToUnload)
{
DEFiRet;
- modInfo_t *pMod;
modInfo_t *pModCurr; /* module currently being processed */
- pMod = GetNxt(NULL);
- while(pMod != NULL) {
- pModCurr = pMod;
- pMod = GetNxt(pModCurr); /* get next */
+ pModCurr = GetNxt(NULL);
+ while(pModCurr != NULL) {
if(modLinkTypesToUnload == eMOD_LINK_ALL || pModCurr->eLinkType == modLinkTypesToUnload) {
- modUnlinkAndDestroy(pModCurr);
+ if(modUnlinkAndDestroy(&pModCurr) == RS_RET_MODULE_STILL_REFERENCED) {
+ pModCurr = GetNxt(pModCurr);
+ }
+ } else {
+ pModCurr = GetNxt(pModCurr);
}
}
@@ -687,7 +695,7 @@ Release(char *srcFile, modInfo_t **ppThis)
if(pThis->uRefCnt == 0) {
/* we have a zero refcount, so we must unload the module */
dbgprintf("module '%s' has zero reference count, unloading...\n", pThis->pszName);
- modUnlinkAndDestroy(pThis);
+ modUnlinkAndDestroy(&pThis);
*ppThis = NULL; /* nobody can access it any longer! */
}