summaryrefslogtreecommitdiffstats
path: root/runtime/nssel.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/nssel.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/nssel.c')
-rw-r--r--runtime/nssel.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/runtime/nssel.c b/runtime/nssel.c
index 793da9dc..50228208 100644
--- a/runtime/nssel.c
+++ b/runtime/nssel.c
@@ -44,8 +44,6 @@
#include "netstrm.h"
#include "nssel.h"
-MODULE_TYPE_LIB
-
/* static data */
DEFobjStaticHelpers
DEFobjCurrIf(glbl)
@@ -59,6 +57,8 @@ DEFobjCurrIf(glbl)
* a nssel driver. So we simply append "sel" to the nsd driver name: This,
* of course, means that the driver name must match these rules, but that
* shouldn't be a real problem.
+ * WARNING: this code is mostly identical to similar code in
+ * netstrms.c - TODO: abstract it and move it to some common place.
* rgerhards, 2008-04-28
*/
static rsRetVal
@@ -68,11 +68,12 @@ loadDrvr(nssel_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), "lmnsdsel_%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
@@ -82,7 +83,13 @@ loadDrvr(nssel_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;
}
@@ -97,6 +104,15 @@ BEGINobjDestruct(nssel) /* be sure to specify the object type also in END and CO
CODESTARTobjDestruct(nssel)
if(pThis->pDrvrData != NULL)
pThis->Drvr.Destruct(&pThis->pDrvrData);
+
+ /* 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(nssel)
@@ -207,29 +223,5 @@ BEGINObjClassInit(nssel, 1, OBJ_IS_CORE_MODULE) /* class, version */
/* set our own handlers */
ENDObjClassInit(nssel)
-
-
-/* --------------- here now comes the plumbing that makes us a library module --------------- */
-
-
-BEGINmodExit
-CODESTARTmodExit
- nsselClassExit();
-ENDmodExit
-
-
-BEGINqueryEtryPt
-CODESTARTqueryEtryPt
-CODEqueryEtryPt_STD_LIB_QUERIES
-ENDqueryEtryPt
-
-
-BEGINmodInit()
-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(nsselClassInit(pModInfo)); /* must be done after tcps_sess, as we use it */
-ENDmodInit
/* vi:set ai:
*/