summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-04-29 15:36:22 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-04-29 15:36:22 +0200
commit055d4ffc2afc77e03a3d31720d4a0998f8c3d92c (patch)
treebab872b075c24ba84f6658b5e339759af188591d /runtime
parent1cce2e35b06b54469dd627454c0f58818ff3523a (diff)
downloadrsyslog-055d4ffc2afc77e03a3d31720d4a0998f8c3d92c.tar.gz
rsyslog-055d4ffc2afc77e03a3d31720d4a0998f8c3d92c.tar.xz
rsyslog-055d4ffc2afc77e03a3d31720d4a0998f8c3d92c.zip
fixed problem with module unload sequence
Diffstat (limited to 'runtime')
-rw-r--r--runtime/debug.c2
-rw-r--r--runtime/modules.c13
-rw-r--r--runtime/netstrm.h4
-rw-r--r--runtime/netstrms.c12
-rw-r--r--runtime/nsd_ptcp.c4
-rw-r--r--runtime/nssel.h4
-rw-r--r--runtime/obj.c6
7 files changed, 21 insertions, 24 deletions
diff --git a/runtime/debug.c b/runtime/debug.c
index 53624e38..f543efd8 100644
--- a/runtime/debug.c
+++ b/runtime/debug.c
@@ -1145,8 +1145,6 @@ dbgPrintNameAdd(uchar *pName, dbgPrintName_t **ppRoot)
pEntry->pNext = *ppRoot; /* we enqueue at the front */
}
*ppRoot = pEntry;
-
-printf("Name %s added to %p\n", pName, *ppRoot);
}
diff --git a/runtime/modules.c b/runtime/modules.c
index c156fef2..1e59a5fc 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -522,11 +522,16 @@ modUnloadAndDestructAll(eModLinkType_t modLinkTypesToUnload)
if(modLinkTypesToUnload == eMOD_LINK_ALL || pModCurr->eLinkType == modLinkTypesToUnload) {
if(modUnlinkAndDestroy(&pModCurr) == RS_RET_MODULE_STILL_REFERENCED) {
pModCurr = GetNxt(pModCurr);
+ } else {
+ /* Note: if the module was successfully unloaded, it has updated the
+ * pModCurr pointer to the next module. However, the unload process may
+ * still have indirectly referenced the pointer list in a way that the
+ * unloaded module is not aware of. So we restart the unload process
+ * to make sure we do not fall into a trap (what we did ;)). The
+ * performance toll is minimal. -- rgerhards, 2008-04-28
+ */
+ pModCurr = GetNxt(NULL);
}
- /* Note: if the module was successfully unloaded, it has updated the
- * pModCurr pointer to the next module. So we do NOT need to advance
- * to the next module on successful unload.
- */
} else {
pModCurr = GetNxt(pModCurr);
}
diff --git a/runtime/netstrm.h b/runtime/netstrm.h
index ddf15677..b6a01555 100644
--- a/runtime/netstrm.h
+++ b/runtime/netstrm.h
@@ -24,7 +24,7 @@
#ifndef INCLUDED_NETSTRM_H
#define INCLUDED_NETSTRM_H
-#include "nsd.h" /* we need our driver interface to be defined */
+#include "netstrms.h"
/* the netstrm object */
struct netstrm_s {
@@ -57,6 +57,6 @@ ENDinterface(netstrm)
PROTOTYPEObj(netstrm);
/* the name of our library binary */
-#define LM_NETSTRM_FILENAME "lmnetstrm"
+#define LM_NETSTRM_FILENAME LM_NETSTRMS_FILENAME
#endif /* #ifndef INCLUDED_NETSTRM_H */
diff --git a/runtime/netstrms.c b/runtime/netstrms.c
index 241df9be..501d97dd 100644
--- a/runtime/netstrms.c
+++ b/runtime/netstrms.c
@@ -32,7 +32,6 @@
#include "module-template.h"
#include "obj.h"
//#include "errmsg.h"
-//#include "net.h"
#include "nsd.h"
#include "netstrm.h"
#include "nssel.h"
@@ -45,7 +44,6 @@ DEFobjStaticHelpers
//DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(netstrm)
-//DEFobjCurrIf(net)
/* load our low-level driver. This must be done before any
@@ -130,7 +128,7 @@ CreateStrm(netstrms_t *pThis, netstrm_t **ppStrm)
netstrm_t *pStrm = NULL;
DEFiRet;
- CHKiRet(objUse(netstrm, LM_NETSTRM_FILENAME));
+ CHKiRet(objUse(netstrm, DONT_LOAD_LIB));
CHKiRet(netstrm.Construct(&pStrm));
/* we copy over our driver structure. We could provide a pointer to
* ourselves, but that costs some performance on each driver invocation.
@@ -175,9 +173,8 @@ ENDobjQueryInterface(netstrms)
BEGINObjClassExit(netstrms, OBJ_IS_LOADABLE_MODULE) /* CHANGE class also in END MACRO! */
CODESTARTObjClassExit(netstrms)
/* release objects we no longer need */
- //objRelease(net, CORE_COMPONENT);
objRelease(glbl, CORE_COMPONENT);
- objRelease(netstrm, LM_NETSTRM_FILENAME);
+ objRelease(netstrm, DONT_LOAD_LIB);
ENDObjClassExit(netstrms)
@@ -188,7 +185,6 @@ ENDObjClassExit(netstrms)
BEGINAbstractObjClassInit(netstrms, 1, OBJ_IS_CORE_MODULE) /* class, version */
/* request objects we use */
CHKiRet(objUse(glbl, CORE_COMPONENT));
- //CHKiRet(objUse(net, CORE_COMPONENT));
/* set our own handlers */
ENDObjClassInit(netstrms)
@@ -199,9 +195,9 @@ ENDObjClassInit(netstrms)
BEGINmodExit
CODESTARTmodExit
- netstrmsClassExit();
- netstrmClassExit();
nsselClassExit();
+ netstrmsClassExit();
+ netstrmClassExit(); /* we use this object, so we must exit it after we are finished */
ENDmodExit
diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c
index 5994fee7..e26347c3 100644
--- a/runtime/nsd_ptcp.c
+++ b/runtime/nsd_ptcp.c
@@ -645,7 +645,7 @@ CODESTARTObjClassExit(nsd_ptcp)
objRelease(net, CORE_COMPONENT);
objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
- objRelease(netstrm, LM_NETSTRM_FILENAME);
+ objRelease(netstrm, DONT_LOAD_LIB);
objRelease(netstrms, LM_NETSTRMS_FILENAME);
ENDObjClassExit(nsd_ptcp)
@@ -659,8 +659,8 @@ BEGINObjClassInit(nsd_ptcp, 1, OBJ_IS_LOADABLE_MODULE) /* class, version */
CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(net, CORE_COMPONENT));
- CHKiRet(objUse(netstrm, LM_NETSTRM_FILENAME));
CHKiRet(objUse(netstrms, LM_NETSTRMS_FILENAME));
+ CHKiRet(objUse(netstrm, DONT_LOAD_LIB));
/* set our own handlers */
ENDObjClassInit(nsd_ptcp)
diff --git a/runtime/nssel.h b/runtime/nssel.h
index d54f408d..8cb34f5a 100644
--- a/runtime/nssel.h
+++ b/runtime/nssel.h
@@ -24,7 +24,7 @@
#ifndef INCLUDED_NSSEL_H
#define INCLUDED_NSSEL_H
-#include "nsd.h"
+#include "netstrms.h"
/* the nssel object */
struct nssel_s {
@@ -51,6 +51,6 @@ ENDinterface(nssel)
PROTOTYPEObj(nssel);
/* the name of our library binary */
-#define LM_NSSEL_FILENAME "lmnssel"
+#define LM_NSSEL_FILENAME LM_NETSTRMS_FILENAME
#endif /* #ifndef INCLUDED_NSSEL_H */
diff --git a/runtime/obj.c b/runtime/obj.c
index 18a4a726..312ed223 100644
--- a/runtime/obj.c
+++ b/runtime/obj.c
@@ -1192,15 +1192,14 @@ ReleaseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf)
objInfo_t *pObjInfo;
- dbgprintf("source file %s requests object '%s', ifIsLoaded %d\n", srcFile, pObjName, pIf->ifIsLoaded);
+ dbgprintf("source file %s releasing object '%s', ifIsLoaded %d\n", srcFile, pObjName, pIf->ifIsLoaded);
if(pObjFile == NULL)
FINALIZE; /* if it is not a lodable module, we do not need to do anything... */
if(pIf->ifIsLoaded == 0) {
ABORT_FINALIZE(RS_RET_OK); /* we are not loaded - this is perfectly OK... */
- }
- if(pIf->ifIsLoaded == 2) {
+ } else if(pIf->ifIsLoaded == 2) {
pIf->ifIsLoaded = 0; /* clean up */
ABORT_FINALIZE(RS_RET_OK); /* we had a load error and can not continue */
}
@@ -1209,7 +1208,6 @@ ReleaseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf)
CHKiRet(FindObjInfo(pStr, &pObjInfo));
/* if we reach this point, we have a valid pObjInfo */
- //if(pObjInfo->pModInfo != NULL) { /* NULL means core module */
module.Release(srcFile, &pObjInfo->pModInfo); /* decrease refcount */
pIf->ifIsLoaded = 0; /* indicated "no longer valid" */