summaryrefslogtreecommitdiffstats
path: root/runtime
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 /runtime
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 'runtime')
-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
5 files changed, 45 insertions, 9 deletions
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)