diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-06-06 18:49:32 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-06-06 18:49:32 +0200 |
commit | 27360bb33ff5e87a3852ebe2673170ebea168421 (patch) | |
tree | 4b172b4c41a32ee2baa1baceb2b23339ace077f9 /runtime | |
parent | f8ab9d166648f2b3af11bc3523e192bb3cd79219 (diff) | |
parent | 29cd813960ed8e4f800cb9210d30888368587f1c (diff) | |
download | rsyslog-27360bb33ff5e87a3852ebe2673170ebea168421.tar.gz rsyslog-27360bb33ff5e87a3852ebe2673170ebea168421.tar.xz rsyslog-27360bb33ff5e87a3852ebe2673170ebea168421.zip |
Merge branch 'v5-beta' into beta
Conflicts:
runtime/modules.c
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/cfsysline.c | 18 | ||||
-rw-r--r-- | runtime/modules.c | 31 | ||||
-rw-r--r-- | runtime/msg.c | 2 | ||||
-rw-r--r-- | runtime/obj.c | 4 | ||||
-rw-r--r-- | runtime/obj.h | 4 |
5 files changed, 26 insertions, 33 deletions
diff --git a/runtime/cfsysline.c b/runtime/cfsysline.c index af88b3de..d8c33169 100644 --- a/runtime/cfsysline.c +++ b/runtime/cfsysline.c @@ -346,11 +346,12 @@ static int doParseOnOffOption(uchar **pp) */ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal) { - struct group *pgBuf; + struct group *pgBuf = NULL; struct group gBuf; DEFiRet; uchar szName[256]; - char stringBuf[2048]; /* I hope this is large enough... */ + int bufSize = 2048; + char * stringBuf = NULL; assert(pp != NULL); assert(*pp != NULL); @@ -360,7 +361,17 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p ABORT_FINALIZE(RS_RET_NOT_FOUND); } - getgrnam_r((char*)szName, &gBuf, stringBuf, sizeof(stringBuf), &pgBuf); + + CHKmalloc(stringBuf = malloc(bufSize)); + while(pgBuf == NULL) { + errno = 0; + getgrnam_r((char*)szName, &gBuf, stringBuf, bufSize, &pgBuf); + if((pgBuf == NULL) && (errno == ERANGE)) { + /* Increase bufsize and try again.*/ + bufSize *= 2; + CHKmalloc(stringBuf = realloc(stringBuf, bufSize)); + } + } if(pgBuf == NULL) { errmsg.LogError(0, RS_RET_NOT_FOUND, "ID for group '%s' could not be found or error", (char*)szName); @@ -379,6 +390,7 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p skipWhiteSpace(pp); /* skip over any whitespace */ finalize_it: + free(stringBuf); RETiRet; } diff --git a/runtime/modules.c b/runtime/modules.c index 5a87c8be..dac3bd95 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -67,14 +67,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 */ @@ -819,7 +811,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) { @@ -855,7 +847,7 @@ modUnlinkAndDestroy(modInfo_t **ppThis) moduleDestruct(pThis); finalize_it: - pthread_mutex_unlock(&mutLoadUnload); + pthread_mutex_unlock(&mutObjGlobalOp); RETiRet; } @@ -970,7 +962,7 @@ Load(uchar *pModName, sbool bConfLoad) */ # 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; @@ -1096,7 +1088,7 @@ Load(uchar *pModName, sbool bConfLoad) finalize_it: if(pPathBuf != pathBuf) /* used malloc()ed memory? */ free(pPathBuf); - pthread_mutex_unlock(&mutLoadUnload); + pthread_mutex_unlock(&mutObjGlobalOp); RETiRet; } @@ -1193,16 +1185,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); - */ - free(pModDir); # ifdef DEBUG modUsrPrintAll(); /* debug aid - TODO: integrate with debug.c, at least the settings! */ @@ -1246,7 +1228,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) { @@ -1264,10 +1245,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) diff --git a/runtime/msg.c b/runtime/msg.c index 4ad2b89e..4df13031 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1638,7 +1638,7 @@ char *getPROCID(msg_t *pM, sbool bLockMutex) MsgLock(pM); preparePROCID(pM, MUTEX_ALREADY_LOCKED); if(pM->pCSPROCID == NULL) - pszRet = UCHAR_CONSTANT(""); + pszRet = UCHAR_CONSTANT("-"); else pszRet = rsCStrGetSzStrNoNULL(pM->pCSPROCID); if(bLockMutex == LOCK_MUTEX) diff --git a/runtime/obj.c b/runtime/obj.c index 93fbd281..b2739c58 100644 --- a/runtime/obj.c +++ b/runtime/obj.c @@ -96,7 +96,7 @@ DEFobjCurrIf(module) DEFobjCurrIf(errmsg) DEFobjCurrIf(strm) static objInfo_t *arrObjInfo[OBJ_NUM_IDS]; /* array with object information pointers */ -static pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of the object system */ +pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of the object system */ /* cookies for serialized lines */ @@ -1318,7 +1318,7 @@ objClassInit(modInfo_t *pModInfo) } /* the mutex must be recursive, because objects may call into other - * object identifieres recursively. + * object identifiers recursively. */ pthread_mutexattr_init(&mutAttr); pthread_mutexattr_settype(&mutAttr, PTHREAD_MUTEX_RECURSIVE); diff --git a/runtime/obj.h b/runtime/obj.h index be97f20e..32f7ef09 100644 --- a/runtime/obj.h +++ b/runtime/obj.h @@ -122,4 +122,8 @@ rsRetVal objGetObjInterface(obj_if_t *pIf); PROTOTYPEObjClassInit(obj); PROTOTYPEObjClassExit(obj); + +/* the following definition is only for "friends" */ +extern pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of the object system */ + #endif /* #ifndef OBJ_H_INCLUDED */ |