diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-26 14:09:08 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-26 14:09:08 +0000 |
commit | 19f8866bb1bbccd0abd18838251d242c1b81b7cc (patch) | |
tree | 7b3b4803ec1961cd6896976019c39adb2a9c7683 | |
parent | 258300adfd7d2dc620bac24037bdea1a290215a5 (diff) | |
download | rsyslog-19f8866bb1bbccd0abd18838251d242c1b81b7cc.tar.gz rsyslog-19f8866bb1bbccd0abd18838251d242c1b81b7cc.tar.xz rsyslog-19f8866bb1bbccd0abd18838251d242c1b81b7cc.zip |
bugfix: rsyslogd segfaulted on second SIGHUP tracker:
http://bugzilla.adiscon.com/show_bug.cgi?id=38
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | modules.c | 56 | ||||
-rw-r--r-- | syslogd.c | 2 |
3 files changed, 49 insertions, 11 deletions
@@ -5,6 +5,8 @@ Version 3.11.6 (rgerhards), 2008-02-?? - enabled imgssapi to be loaded side-by-side with imtcp - added InputGSSServerPermitPlainTCP config directive - split imgssapi source code somewhat from imtcp +- bugfix: rsyslogd segfaulted on second SIGHUP + tracker: http://bugzilla.adiscon.com/show_bug.cgi?id=38 - applied patch from varmojfekoj to fix an issue with compatibility mode and default module directories (many thanks!): I've also noticed a bug in the compatibility code; the problem is that @@ -348,33 +348,69 @@ rsRetVal modUnloadAndDestructAll(void) moduleDestruct(pModPrev); } + /* indicate list is now empty */ + pLoadedModules = NULL; + pLoadedModulesLast = NULL; + RETiRet; } +/* unlink and destroy a module. The caller must provide a pointer to the module + * itself as well as one to its immediate predecessor. + * rgerhards, 2008-02-26 + */ +static rsRetVal +modUnlinkAndDestroy(modInfo_t *pThis, modInfo_t *pPrev) +{ + DEFiRet; + + /* we need to unlink the module before we can destruct it -- rgerhards, 2008-02-26 */ + if(pPrev == NULL) { + /* module is root, so we need to set a new root */ + pLoadedModules = pThis->pNext; + } else { + pPrev->pNext = pThis->pNext; + } + + /* check if we need to update the "last" pointer */ + if(pLoadedModulesLast == pThis) { + pLoadedModulesLast = pPrev; + } + + /* finally, we are ready for the module to go away... */ + dbgprintf("Unloading module %s\n", modGetName(pThis)); + modPrepareUnload(pThis); + moduleDestruct(pThis); + + RETiRet; +} + + +/* unload dynamically loaded modules + */ rsRetVal modUnloadAndDestructDynamic(void) { DEFiRet; modInfo_t *pMod; - modInfo_t *pModPrev; - - pLoadedModulesLast = NULL; + modInfo_t *pModCurr; /* module currently being processed */ + modInfo_t *pModPrev; /* last module in active linked list */ + pModPrev = NULL; /* we do not yet have a previous module */ pMod = modGetNxt(NULL); while(pMod != NULL) { - pModPrev = pMod; - pMod = modGetNxt(pModPrev); /* get next */ + pModCurr = pMod; + pMod = modGetNxt(pModCurr); /* get next */ /* now we can destroy the previous module */ - if(pModPrev->eLinkType != eMOD_LINK_STATIC) { - dbgprintf("Unloading module %s\n", modGetName(pModPrev)); - modPrepareUnload(pModPrev); - moduleDestruct(pModPrev); + if(pModCurr->eLinkType != eMOD_LINK_STATIC) { + modUnlinkAndDestroy(pModCurr, pModPrev); } else { - pLoadedModulesLast = pModPrev; + pModPrev = pModCurr; /* don't delete, so this is the new prev ptr */ } } RETiRet; } + /* vi:set ai: */ @@ -2464,7 +2464,7 @@ static void doDie(int sig) printf("DoDie called.\n"); if(iRetries++ == 4) { printf("DoDie called 5 times - unconditional exit\n"); - exit(1); + abort(); } bFinished = sig; } |