--- rsyslog/cfsysline.c.orig 2007-08-16 23:33:00.000000000 +0200 +++ rsyslog/cfsysline.c 2007-08-16 23:44:10.000000000 +0200 @@ -573,6 +573,12 @@ finalize_it: } +rsRetVal unregCfSysLineHdlrs(void) +{ + return llDestroy(&llCmdList); +} + + /* process a cfsysline command (based on handler structure) * param "p" is a pointer to the command line after the command. Should be * updated. --- rsyslog/cfsysline.h.orig 2007-08-16 23:33:10.000000000 +0200 +++ rsyslog/cfsysline.h 2007-08-16 23:44:23.000000000 +0200 @@ -61,6 +61,7 @@ typedef struct cslCmd_s cslCmd_t; /* prototypes */ rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData); +rsRetVal unregCfSysLineHdlrs(void); rsRetVal processCfSysLineCommand(uchar *pCmd, uchar **p); rsRetVal cfsyslineInit(void); void dbgPrintCfSysLineHandlers(void); --- rsyslog/syslogd.c.orig 2007-08-16 23:45:27.000000000 +0200 +++ rsyslog/syslogd.c 2007-08-17 11:23:54.000000000 +0200 @@ -3552,7 +3552,7 @@ static void die(int sig) /* de-init some modules */ modExitIminternal(); - /*TODO: the module config command handlers must also be freed! */ + unregCfSysLineHdlrs(); /* TODO: this would also be the right place to de-init the builtin output modules. We * do not currently do that, because the module interface does not allow for @@ -4259,6 +4259,10 @@ static void init(void) /* Close all open log files and free log descriptor array. */ freeSelectors(); + /* Unload all non-static modules */ + dbgprintf("Unloading non-static modules.\n"); + modUnloadAndDestructDynamic(); + dbgprintf("Clearing templates.\n"); tplDeleteNew(); --- rsyslog/ommysql.c.orig 2007-08-17 11:02:00.000000000 +0200 +++ rsyslog/ommysql.c 2007-08-17 11:02:02.000000000 +0200 @@ -79,6 +79,7 @@ static void closeMySQL(instanceData *pDa assert(pData != NULL); if(pData->f_hmysql != NULL) { /* just to be on the safe side... */ + mysql_server_end(); mysql_close(pData->f_hmysql); pData->f_hmysql = NULL; } --- rsyslog/modules.c.orig 2007-08-21 09:43:48.000000000 +0200 +++ rsyslog/modules.c 2007-08-21 09:07:17.000000000 +0200 @@ -336,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: */ --- rsyslog/modules.h.orig 2007-08-17 11:11:26.000000000 +0200 +++ rsyslog/modules.h 2007-08-17 11:15:35.000000000 +0200 @@ -94,6 +94,7 @@ uchar *modGetName(modInfo_t *pThis); uchar *modGetStateName(modInfo_t *pThis); void modPrintList(void); rsRetVal modUnloadAndDestructAll(void); +rsRetVal modUnloadAndDestructDynamic(void); #endif /* #ifndef MODULES_H_INCLUDED */ /*