summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-06-25 12:35:46 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-06-25 12:35:46 +0200
commitbf85d81790a26945e404c6fdfdddad5eadbaa371 (patch)
tree5b9e97ea2c78e9450f58971ecae3234ba7eb3c85 /tools
parent4b150db338ae885ea3a3bb7cc5b5f84e2fc96e89 (diff)
downloadrsyslog-bf85d81790a26945e404c6fdfdddad5eadbaa371.tar.gz
rsyslog-bf85d81790a26945e404c6fdfdddad5eadbaa371.tar.xz
rsyslog-bf85d81790a26945e404c6fdfdddad5eadbaa371.zip
implemented freeCnf() module interface & fixed some mem leaks
The interface was actually not present in older versions, even though some modules already used it. The implementation was now done, and not in 6.3/6.4 because the resulting memory leak was ultra-slim and the new interface handling has some potential to seriously break things. Not the kind of thing you want to add in late beta state, if avoidable.
Diffstat (limited to 'tools')
-rw-r--r--tools/omfile.c12
-rw-r--r--tools/syslogd.c27
2 files changed, 12 insertions, 27 deletions
diff --git a/tools/omfile.c b/tools/omfile.c
index e9f4cba8..446e1b32 100644
--- a/tools/omfile.c
+++ b/tools/omfile.c
@@ -182,7 +182,6 @@ uchar *pszFileDfltTplName; /* name of the default template to use */
struct modConfData_s {
rsconf_t *pConf; /* our overall config object */
- struct cnfparamvals* vals; /* vals kept to detect re-set options */
uchar *tplName; /* default template */
};
@@ -292,6 +291,7 @@ setLegacyDfltTpl(void __attribute__((unused)) *pVal, uchar* newVal)
DEFiRet;
if(loadModConf != NULL && loadModConf->tplName != NULL) {
+ free(newVal);
errmsg.LogError(0, RS_RET_ERR, "omfile default template already set via module "
"global parameter - can no longer be changed");
ABORT_FINALIZE(RS_RET_ERR);
@@ -754,16 +754,15 @@ CODESTARTbeginCnfLoad
ENDbeginCnfLoad
BEGINsetModCnf
- struct cnfparamvals *pvals;
+ struct cnfparamvals *pvals = NULL;
int i;
CODESTARTsetModCnf
- loadModConf->vals = nvlstGetParams(lst, &modpblk, loadModConf->vals);
- if(loadModConf->vals == NULL) {
+ pvals = nvlstGetParams(lst, &modpblk, NULL);
+ if(pvals == NULL) {
errmsg.LogError(0, RS_RET_MISSING_CNFPARAMS, "error processing module "
"config parameters [module(...)]");
ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS);
}
- pvals = loadModConf->vals;
if(Debug) {
dbgprintf("module (global) param blk for omfile:\n");
@@ -786,6 +785,8 @@ CODESTARTsetModCnf
}
}
finalize_it:
+ if(pvals != NULL)
+ cnfparamvalsDestruct(pvals, &modpblk);
ENDsetModCnf
BEGINendCnfLoad
@@ -809,6 +810,7 @@ ENDactivateCnf
BEGINfreeCnf
CODESTARTfreeCnf
+ free(pModConf->tplName);
ENDfreeCnf
diff --git a/tools/syslogd.c b/tools/syslogd.c
index b84aae22..20a4aa12 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -786,18 +786,6 @@ static void doDie(int sig)
}
-/* This function frees all dynamically allocated memory for program termination.
- * It must be called only immediately before exit(). It is primarily an aid
- * for memory debuggers, which prevents cluttered outupt.
- * rgerhards, 2008-03-20
- */
-static void
-freeAllDynMemForTermination(void)
-{
- free(ourConf->globals.pszConfDAGFile);
-}
-
-
/* Finalize and destruct all actions.
*/
static inline void
@@ -867,14 +855,16 @@ die(int sig)
destructAllActions();
DBGPRINTF("all primary multi-thread sources have been terminated - now doing aux cleanup...\n");
+
+ DBGPRINTF("destructing current config...\n");
+ rsconf.Destruct(&runConf);
+
/* rger 2005-02-22
* now clean up the in-memory structures. OK, the OS
* would also take care of that, but if we do it
* ourselfs, this makes finding memory leaks a lot
* easier.
*/
- tplDeleteAll(runConf);
-
/* de-init some modules */
modExitIminternal();
@@ -898,15 +888,8 @@ die(int sig)
/* dbgClassExit MUST be the last one, because it de-inits the debug system */
dbgClassExit();
- /* free all remaining memory blocks - this is not absolutely necessary, but helps
- * us keep memory debugger logs clean and this is in aid in developing. It doesn't
- * cost much time, so we do it always. -- rgerhards, 2008-03-20
- */
- freeAllDynMemForTermination();
- /* NO CODE HERE - feeelAllDynMemForTermination() must be the last thing before exit()! */
-
+ /* NO CODE HERE - dbgClassExit() must be the last thing before exit()! */
remove_pid(PidFile);
-
exit(0); /* "good" exit, this is the terminator function for rsyslog [die()] */
}