diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-06-06 15:12:51 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-06-06 15:12:51 +0200 |
commit | 29cd813960ed8e4f800cb9210d30888368587f1c (patch) | |
tree | 7fd216d79c33106fb12bf744f995480f8665f357 /runtime/modules.c | |
parent | d6602c1a6cfd48ff1f5b7656eb429d60ce927ebc (diff) | |
parent | 7f109cca88816752a9c9cbe255df9e3a5b5a8b5a (diff) | |
download | rsyslog-29cd813960ed8e4f800cb9210d30888368587f1c.tar.gz rsyslog-29cd813960ed8e4f800cb9210d30888368587f1c.tar.xz rsyslog-29cd813960ed8e4f800cb9210d30888368587f1c.zip |
Merge branch 'v5-stable' into v5-beta
Conflicts:
ChangeLog
configure.ac
doc/manual.html
runtime/modules.c
Diffstat (limited to 'runtime/modules.c')
-rw-r--r-- | runtime/modules.c | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/runtime/modules.c b/runtime/modules.c index 6a32b2e8..b353e983 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -66,14 +66,6 @@ DEFobjCurrIf(errmsg) DEFobjCurrIf(parser) DEFobjCurrIf(strgen) -/* we must ensure that only one thread at one time tries to load or unload - * modules, otherwise we may see race conditions. This first came up with - * imdiag/imtcp, which both use the same stream drivers. Below is the mutex - * for that handling. - * rgerhards, 2009-05-25 - */ -static pthread_mutex_t mutLoadUnload; - static modInfo_t *pLoadedModules = NULL; /* list of currently-loaded modules */ static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */ @@ -667,7 +659,7 @@ modUnlinkAndDestroy(modInfo_t **ppThis) pThis = *ppThis; assert(pThis != NULL); - pthread_mutex_lock(&mutLoadUnload); + pthread_mutex_lock(&mutObjGlobalOp); /* first check if we are permitted to unload */ if(pThis->eType == eMOD_LIB) { @@ -703,7 +695,7 @@ modUnlinkAndDestroy(modInfo_t **ppThis) moduleDestruct(pThis); finalize_it: - pthread_mutex_unlock(&mutLoadUnload); + pthread_mutex_unlock(&mutObjGlobalOp); RETiRet; } @@ -791,7 +783,7 @@ Load(uchar *pModName) */ # define PATHBUF_OVERHEAD 1 + iModNameLen + 3 + 1 - pthread_mutex_lock(&mutLoadUnload); + pthread_mutex_lock(&mutObjGlobalOp); if(iModNameLen > 3 && !strcmp((char *) pModName + iModNameLen - 3, ".so")) { iModNameLen -= 3; @@ -915,7 +907,7 @@ Load(uchar *pModName) finalize_it: if(pPathBuf != pathBuf) /* used malloc()ed memory? */ free(pPathBuf); - pthread_mutex_unlock(&mutLoadUnload); + pthread_mutex_unlock(&mutObjGlobalOp); RETiRet; } @@ -1012,16 +1004,6 @@ CODESTARTObjClassExit(module) /* release objects we no longer need */ objRelease(errmsg, CORE_COMPONENT); objRelease(parser, CORE_COMPONENT); - /* We have a problem in our reference counting, which leads to this function - * being called too early. This usually is no problem, but if we destroy - * the mutex object, we get into trouble. So rather than finding the root cause, - * we do not release the mutex right now and have a very, very slight leak. - * We know that otherwise no bad effects happen, so this acceptable for the - * time being. -- rgerhards, 2009-05-25 - * - * TODO: add again: pthread_mutex_destroy(&mutLoadUnload); - */ - # ifdef DEBUG modUsrPrintAll(); /* debug aid - TODO: integrate with debug.c, at least the settings! */ # endif @@ -1063,7 +1045,6 @@ ENDobjQueryInterface(module) */ BEGINAbstractObjClassInit(module, 1, OBJ_IS_CORE_MODULE) /* class, version - CHANGE class also in END MACRO! */ uchar *pModPath; - pthread_mutexattr_t mutAttr; /* use any module load path specified in the environment */ if((pModPath = (uchar*) getenv("RSYSLOG_MODDIR")) != NULL) { @@ -1081,10 +1062,6 @@ BEGINAbstractObjClassInit(module, 1, OBJ_IS_CORE_MODULE) /* class, version - CHA SetModDir(glblModPath); } - pthread_mutexattr_init(&mutAttr); - pthread_mutexattr_settype(&mutAttr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mutLoadUnload, &mutAttr); - /* request objects we use */ CHKiRet(objUse(errmsg, CORE_COMPONENT)); ENDObjClassInit(module) |