diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-06-08 08:25:56 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-06-08 08:25:56 +0200 |
commit | 220c57e7ebc49a56cc91fa31308b1563f83a95fb (patch) | |
tree | b4295619e3121daa9766c38b542b15d6c5669760 /tools | |
parent | d9e64c16e52357bae1eb00fc8403c4e63d6365ca (diff) | |
download | rsyslog-220c57e7ebc49a56cc91fa31308b1563f83a95fb.tar.gz rsyslog-220c57e7ebc49a56cc91fa31308b1563f83a95fb.tar.xz rsyslog-220c57e7ebc49a56cc91fa31308b1563f83a95fb.zip |
bugfix: regression caused more locking action in msg.c than necessary
also: bugfix: mutexes used to similate atomic instructions were not destructed
Diffstat (limited to 'tools')
-rw-r--r-- | tools/omfile.c | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/tools/omfile.c b/tools/omfile.c index 5e49afa9..92089a59 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -92,33 +92,15 @@ static uint64 clockFileAccess = 0; static unsigned clockFileAccess = 0; #endif /* and the "tick" function */ -#ifdef HAVE_ATOMIC_BUILTINS -static inline uint64 -getClockFileAccess(void) -{ - return ATOMIC_INC_AND_FETCH(clockFileAccess); -} -#else -/* if we do not have atomics, we need to guard this via a mutex. - * the reason is that otherwise cache lookups may fail. That function - * requires the highest current value, and we can not provide that - * without using atomic instructions and mutexes. - * rgerhards, 2010-03-05 - */ +#ifndef HAVE_ATOMIC_BUILTINS static pthread_mutex_t mutClock; -static uint64 +#endif +static inline uint64 getClockFileAccess(void) { - uint64 retVal; - - BEGINfunc - d_pthread_mutex_lock(&mutClock); - retVal = ++clockFileAccess; - d_pthread_mutex_unlock(&mutClock); - ENDfunc - return retVal; + return ATOMIC_INC_AND_FETCH(&clockFileAccess, &mutClock); } -#endif /* #ifdef HAVE_ATOMIC_BUILTINS */ + /* The following structure is a dynafile name cache entry. */ @@ -879,9 +861,7 @@ CODESTARTmodExit objRelease(errmsg, CORE_COMPONENT); objRelease(strm, CORE_COMPONENT); free(pszFileDfltTplName); -# ifndef HAVE_ATOMIC_BUILTINS - pthread_mutex_destroy(&mutClock); -# endif + DESTROY_ATOMIC_HELPER_MUT(mutClock); ENDmodExit @@ -900,9 +880,7 @@ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); CHKiRet(objUse(strm, CORE_COMPONENT)); -# ifndef HAVE_ATOMIC_BUILTINS - pthread_mutex_init(&mutClock, NULL); -# endif + INIT_ATOMIC_HELPER_MUT(mutClock); INITChkCoreFeature(bCoreSupportsBatching, CORE_FEATURE_BATCHING); DBGPRINTF("omfile: %susing transactional output interface.\n", bCoreSupportsBatching ? "" : "not "); |