diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-09-15 15:17:47 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-09-15 15:17:47 +0200 |
commit | 1d0e4ba3b34464343c388ccef3ca8b08df42076a (patch) | |
tree | d17f746f7c8cb2f00aa3ab956740fd616e2390c0 /runtime/msg.c | |
parent | b7e69a240037277e77685af5ea5623cdd89ec2d2 (diff) | |
parent | 11ee5cbdfb08ba3e42a853c08144fa24cd55d6da (diff) | |
download | rsyslog-1d0e4ba3b34464343c388ccef3ca8b08df42076a.tar.gz rsyslog-1d0e4ba3b34464343c388ccef3ca8b08df42076a.tar.bz2 rsyslog-1d0e4ba3b34464343c388ccef3ca8b08df42076a.zip |
Merge branch 'v4-stable' of git+ssh://git.adiscon.com/git/rsyslog into v4-stable
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index c8046d1b..6335f462 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -748,7 +748,7 @@ BEGINobjDestruct(msg) /* be sure to specify the object type also in END and CODE CODESTARTobjDestruct(msg) /* DEV Debugging only ! dbgprintf("msgDestruct\t0x%lx, Ref now: %d\n", (unsigned long)pThis, pThis->iRefCount - 1); */ # ifdef HAVE_ATOMIC_BUILTINS - currRefCount = ATOMIC_DEC_AND_FETCH(pThis->iRefCount); + currRefCount = ATOMIC_DEC_AND_FETCH(&pThis->iRefCount, NULL); # else MsgLock(pThis); currRefCount = --pThis->iRefCount; @@ -800,9 +800,18 @@ CODESTARTobjDestruct(msg) * that we trim too often when the counter wraps. */ static unsigned iTrimCtr = 1; +# ifdef HAVE_ATOMICS if(ATOMIC_INC_AND_FETCH(iTrimCtr) % 100000 == 0) { malloc_trim(128*1024); } +# else +static pthread_mutex_t mutTrimCtr = PTHREAD_MUTEX_INITIALIZER; + d_pthread_mutex_lock(&mutTrimCtr); + if(iTrimCtr++ % 100000 == 0) { + malloc_trim(128*1024); + } + d_pthread_mutex_unlock(&mutTrimCtr); +# endif } # endif } else { @@ -1002,7 +1011,7 @@ msg_t *MsgAddRef(msg_t *pM) { assert(pM != NULL); # ifdef HAVE_ATOMIC_BUILTINS - ATOMIC_INC(pM->iRefCount); + ATOMIC_INC(&pM->iRefCount, NULL); # else MsgLock(pM); pM->iRefCount++; @@ -3046,7 +3055,7 @@ static rsRetVal msgConstructFinalizer(msg_t *pThis) * rgerhards, 2008-01-14 */ static rsRetVal -MsgGetSeverity(obj_t *pThis, int *piSeverity) +MsgGetSeverity(obj_t_ptr pThis, int *piSeverity) { ISOBJ_TYPE_assert(pThis, msg); assert(piSeverity != NULL); |