summaryrefslogtreecommitdiffstats
path: root/runtime/netstrms.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-04-29 12:21:52 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-04-29 12:21:52 +0200
commit1cce2e35b06b54469dd627454c0f58818ff3523a (patch)
tree42b836cda5c3f895949ced7e7afa4702271c6197 /runtime/netstrms.c
parent94acfb1c5f349ede619639e8cb84f2e3d3c28efe (diff)
downloadrsyslog-1cce2e35b06b54469dd627454c0f58818ff3523a.tar.gz
rsyslog-1cce2e35b06b54469dd627454c0f58818ff3523a.tar.xz
rsyslog-1cce2e35b06b54469dd627454c0f58818ff3523a.zip
removed loadbale module leak
- moved netstrms, netstrm and nssel into a single loadble module because they belong together - fixed "loadbale module leak"
Diffstat (limited to 'runtime/netstrms.c')
-rw-r--r--runtime/netstrms.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/runtime/netstrms.c b/runtime/netstrms.c
index dc9d0b69..241df9be 100644
--- a/runtime/netstrms.c
+++ b/runtime/netstrms.c
@@ -35,6 +35,7 @@
//#include "net.h"
#include "nsd.h"
#include "netstrm.h"
+#include "nssel.h"
#include "netstrms.h"
MODULE_TYPE_LIB
@@ -51,6 +52,8 @@ DEFobjCurrIf(netstrm)
* driver-specific functions (allmost all...) can be carried
* out. Note that the driver's .ifIsLoaded is correctly
* initialized by calloc() and we depend on that.
+ * WARNING: this code is mostly identical to similar code in
+ * nssel.c - TODO: abstract it and move it to some common place.
* rgerhards, 2008-04-18
*/
static rsRetVal
@@ -60,11 +63,12 @@ loadDrvr(netstrms_t *pThis)
uchar *pBaseDrvrName;
uchar szDrvrName[48]; /* 48 shall be large enough */
- pBaseDrvrName = pThis->pDrvrName;
+ pBaseDrvrName = pThis->pBaseDrvrName;
if(pBaseDrvrName == NULL) /* if no drvr name is set, use system default */
pBaseDrvrName = glbl.GetDfltNetstrmDrvr();
if(snprintf((char*)szDrvrName, sizeof(szDrvrName), "lmnsd_%s", pBaseDrvrName) == sizeof(szDrvrName))
ABORT_FINALIZE(RS_RET_DRVRNAME_TOO_LONG);
+ CHKmalloc(pThis->pDrvrName = (uchar*) strdup((char*)szDrvrName));
pThis->Drvr.ifVersion = nsdCURR_IF_VERSION;
/* The pDrvrName+2 below is a hack to obtain the object name. It
@@ -74,7 +78,13 @@ loadDrvr(netstrms_t *pThis)
* enough. -- rgerhards, 2008-04-18
*/
CHKiRet(obj.UseObj(__FILE__, szDrvrName+2, szDrvrName, (void*) &pThis->Drvr));
+
finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pThis->pDrvrName != NULL)
+ free(pThis->pDrvrName);
+ pThis->pDrvrName = NULL;
+ }
RETiRet;
}
@@ -87,8 +97,14 @@ ENDobjConstruct(netstrms)
/* destructor for the netstrms object */
BEGINobjDestruct(netstrms) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(netstrms)
- if(pThis->pDrvrName != NULL)
+ /* and now we must release our driver, if we got one. We use the presence of
+ * a driver name string as load indicator (because we also need that string
+ * to release the driver
+ */
+ if(pThis->pDrvrName != NULL) {
+ obj.ReleaseObj(__FILE__, pThis->pDrvrName+2, pThis->pDrvrName, (void*) &pThis->Drvr);
free(pThis->pDrvrName);
+ }
ENDobjDestruct(netstrms)
@@ -184,6 +200,8 @@ ENDObjClassInit(netstrms)
BEGINmodExit
CODESTARTmodExit
netstrmsClassExit();
+ netstrmClassExit();
+ nsselClassExit();
ENDmodExit
@@ -198,7 +216,9 @@ CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
/* Initialize all classes that are in our module - this includes ourselfs */
- CHKiRet(netstrmsClassInit(pModInfo)); /* must be done after tcps_sess, as we use it */
+ CHKiRet(netstrmClassInit(pModInfo));
+ CHKiRet(nsselClassInit(pModInfo));
+ CHKiRet(netstrmsClassInit(pModInfo));
ENDmodInit
/* vi:set ai:
*/