summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--plugins/imtcp/imtcp.c9
-rw-r--r--plugins/imudp/imudp.c9
-rw-r--r--plugins/imuxsock/imuxsock.c8
-rw-r--r--runtime/modules.c22
-rw-r--r--runtime/modules.h3
-rw-r--r--runtime/rsconf.c26
-rw-r--r--runtime/rsconf.h2
-rw-r--r--runtime/rule.c1
-rw-r--r--tcpsrv.c2
-rw-r--r--tools/omfile.c12
-rw-r--r--tools/syslogd.c27
12 files changed, 90 insertions, 37 deletions
diff --git a/ChangeLog b/ChangeLog
index 08aad36b..c4361d3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
Version 6.5.0 [devel] 2012-0?-??
- imrelp now supports non-cancel thread termination
(but now requires at least librelp 1.0.1)
+- implemented freeCnf() module interface
+ This 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.
- added --enable-debugless configure option for very high demanding envs
This actually at compile time disables a lot of debug code, resulting
in some speedup (but serious loss of debugging capabilities)
diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c
index 33404fee..a3365d44 100644
--- a/plugins/imtcp/imtcp.c
+++ b/plugins/imtcp/imtcp.c
@@ -366,7 +366,16 @@ ENDactivateCnf
BEGINfreeCnf
+ instanceConf_t *inst, *del;
CODESTARTfreeCnf
+ for(inst = pModConf->root ; inst != NULL ; ) {
+ free(inst->pszBindPort);
+ free(inst->pBindRuleset);
+ free(inst->pszInputName);
+ del = inst;
+ inst = inst->next;
+ free(del);
+ }
ENDfreeCnf
/* This function is called to gather input.
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index 6abeab07..165b6680 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -751,7 +751,16 @@ ENDactivateCnf
BEGINfreeCnf
+ instanceConf_t *inst, *del;
CODESTARTfreeCnf
+ for(inst = pModConf->root ; inst != NULL ; ) {
+ free(inst->pszBindPort);
+ free(inst->pszBindAddr);
+ free(inst->pBindRuleset);
+ del = inst;
+ inst = inst->next;
+ free(del);
+ }
ENDfreeCnf
/* This function is called to gather input.
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 19028470..eeb18fd2 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -1085,8 +1085,16 @@ ENDactivateCnf
BEGINfreeCnf
+ instanceConf_t *inst, *del;
CODESTARTfreeCnf
free(pModConf->pLogSockName);
+ for(inst = pModConf->root ; inst != NULL ; ) {
+ free(inst->sockName);
+ free(inst->pLogHostName);
+ del = inst;
+ inst = inst->next;
+ free(del);
+ }
ENDfreeCnf
diff --git a/runtime/modules.c b/runtime/modules.c
index e7ae72cc..6417cecd 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -1001,11 +1001,19 @@ Load(uchar *pModName, sbool bConfLoad, struct nvlst *lst)
localRet = addModToCnfList(pModInfo);
if(pModInfo->setModCnf != NULL && localRet == RS_RET_OK) {
if(!strncmp((char*)pModName, "builtin:", sizeof("builtin:")-1)) {
- /* for built-in moules, we need to call setModConf,
- * because there is no way to set parameters at load
- * time for obvious reasons...
- */
- pModInfo->setModCnf(lst);
+ if(pModInfo->bSetModCnfCalled) {
+ errmsg.LogError(0, RS_RET_DUP_PARAM,
+ "parameters for built-in module %s already set - ignored\n",
+ pModName);
+ ABORT_FINALIZE(RS_RET_DUP_PARAM);
+ } else {
+ /* for built-in moules, we need to call setModConf,
+ * because there is no way to set parameters at load
+ * time for obvious reasons...
+ */
+ pModInfo->setModCnf(lst);
+ pModInfo->bSetModCnfCalled = 1;
+ }
}
}
}
@@ -1119,8 +1127,10 @@ Load(uchar *pModName, sbool bConfLoad, struct nvlst *lst)
if(bConfLoad) {
addModToCnfList(pModInfo);
- if(pModInfo->setModCnf != NULL)
+ if(pModInfo->setModCnf != NULL) {
pModInfo->setModCnf(lst);
+ pModInfo->bSetModCnfCalled = 1;
+ }
}
finalize_it:
diff --git a/runtime/modules.h b/runtime/modules.h
index b0f7100f..6a143ae3 100644
--- a/runtime/modules.h
+++ b/runtime/modules.h
@@ -101,6 +101,7 @@ struct modInfo_s {
uchar* pszName; /* printable module name, e.g. for dbgprintf */
uchar* cnfName; /* name to be used in config statements (e.g. 'name="omusrmsg"') */
unsigned uRefCnt; /* reference count for this module; 0 -> may be unloaded */
+ sbool bSetModCnfCalled;/* is setModCnf already called? Needed for built-in modules */
/* functions supported by all types of modules */
rsRetVal (*modInit)(int, int*, rsRetVal(**)()); /* initialize the module */
/* be sure to support version handshake! */
@@ -181,7 +182,7 @@ ENDinterface(module)
* - removed GetNxtType, added GetNxtCnfType - 2011-04-27
* v3 (see above)
* v4
- * - added thrid parameter to Load() - 2012-06-20
+ * - added third parameter to Load() - 2012-06-20
*/
/* prototypes */
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index fecd4f29..affa2dd5 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -64,6 +64,7 @@
#include "threads.h"
#include "datetime.h"
#include "parserif.h"
+#include "modules.h"
#include "dirty.h"
/* static data */
@@ -151,11 +152,36 @@ rsRetVal rsconfConstructFinalize(rsconf_t __attribute__((unused)) *pThis)
}
+/* call freeCnf() module entry points AND free the module entries themselfes.
+ */
+static inline void
+freeCnf(rsconf_t *pThis)
+{
+ cfgmodules_etry_t *etry, *del;
+ etry = pThis->modules.root;
+ while(etry != NULL) {
+ if(etry->pMod->beginCnfLoad != NULL) {
+ dbgprintf("calling freeCnf(%p) for module '%s'\n",
+ etry->modCnf, (char*) module.GetName(etry->pMod));
+ etry->pMod->freeCnf(etry->modCnf);
+ }
+ del = etry;
+ etry = etry->next;
+ free(del);
+ }
+}
+
+
/* destructor for the rsconf object */
BEGINobjDestruct(rsconf) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(rsconf)
+dbgprintf("AAA: rsconfObjDesctruct called\n");
+ freeCnf(pThis);
+ tplDeleteAll(pThis);
free(pThis->globals.mainQ.pszMainMsgQFName);
+ free(pThis->globals.pszConfDAGFile);
llDestroy(&(pThis->rulesets.llRulesets));
+dbgprintf("AAA: rsconfObjDesctruct exit\n");
ENDobjDestruct(rsconf)
diff --git a/runtime/rsconf.h b/runtime/rsconf.h
index 8715cf1b..484fec8c 100644
--- a/runtime/rsconf.h
+++ b/runtime/rsconf.h
@@ -97,8 +97,8 @@ struct defaults_s {
struct cfgmodules_etry_s {
cfgmodules_etry_t *next;
modInfo_t *pMod;
- /* the following data is input module specific */
void *modCnf; /* pointer to the input module conf */
+ /* the following data is input module specific */
sbool canActivate; /* OK to activate this config? */
sbool canRun; /* OK to run this config? */
};
diff --git a/runtime/rule.c b/runtime/rule.c
index 254f2f10..6d14199b 100644
--- a/runtime/rule.c
+++ b/runtime/rule.c
@@ -338,7 +338,6 @@ CODESTARTobjDestruct(rule)
} else if(pThis->f_filter_type == FILTER_EXPR) {
cnfexprDestruct(pThis->f_filterData.expr);
}
-#warning: need to destroy expression based filter!
llDestroy(&pThis->llActList);
ENDobjDestruct(rule)
diff --git a/tcpsrv.c b/tcpsrv.c
index df5f2a5f..c5a26322 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -132,7 +132,7 @@ addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort, int bSuppOctetFram)
/* create entry */
CHKmalloc(pEntry = MALLOC(sizeof(tcpLstnPortList_t)));
- pEntry->pszPort = pszPort;
+ CHKmalloc(pEntry->pszPort = ustrdup(pszPort));
pEntry->pSrv = pThis;
pEntry->pRuleset = pThis->pRuleset;
pEntry->bSuppOctetFram = bSuppOctetFram;
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()] */
}