summaryrefslogtreecommitdiffstats
path: root/runtime/msg.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-09-26 16:22:15 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-09-26 16:22:15 +0200
commit96f312f94f127b7bc9a39e5822afdf28a5b2286c (patch)
treede6601ef23c8a438ccf1138a3d050a1d2ba28569 /runtime/msg.c
parent5b43ffdf1bc099a9e9b0696ab939f5eb6d9bef2a (diff)
parentb8e82d59b7aba7da65e4244a29b92274aa50d08d (diff)
downloadrsyslog-96f312f94f127b7bc9a39e5822afdf28a5b2286c.tar.gz
rsyslog-96f312f94f127b7bc9a39e5822afdf28a5b2286c.tar.xz
rsyslog-96f312f94f127b7bc9a39e5822afdf28a5b2286c.zip
Merge branch 'helgrind' into perf
Conflicts: runtime/debug.c
Diffstat (limited to 'runtime/msg.c')
-rw-r--r--runtime/msg.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index 164c3517..8e3749ef 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -273,11 +273,13 @@ BEGINobjDestruct(msg) /* be sure to specify the object type also in END and CODE
int currRefCount;
CODESTARTobjDestruct(msg)
/* DEV Debugging only ! dbgprintf("msgDestruct\t0x%lx, Ref now: %d\n", (unsigned long)pM, pM->iRefCount - 1); */
-# ifdef DO_HAVE_ATOMICS
- currRefCount = ATOMIC_DEC_AND_FETCH(pThis->iRefCount);
-# else
+//# ifdef DO_HAVE_ATOMICS
+// currRefCount = ATOMIC_DEC_AND_FETCH(pThis->iRefCount);
+//# else
+ MsgLock(pThis);
currRefCount = --pThis->iRefCount;
-# endif
+//# endif
+// we need a mutex, because we may be suspended after getting the refcount but before
if(currRefCount == 0)
{
/* DEV Debugging Only! dbgprintf("msgDestruct\t0x%lx, RefCount now 0, doing DESTROY\n", (unsigned long)pThis); */
@@ -337,9 +339,11 @@ CODESTARTobjDestruct(msg)
rsCStrDestruct(&pThis->pCSPROCID);
if(pThis->pCSMSGID != NULL)
rsCStrDestruct(&pThis->pCSMSGID);
+ MsgUnlock(pThis);
funcDeleteMutex(pThis);
} else {
pThis = NULL; /* tell framework not to destructing the object! */
+ MsgUnlock(pThis);
}
ENDobjDestruct(msg)
@@ -483,7 +487,7 @@ finalize_it:
msg_t *MsgAddRef(msg_t *pM)
{
assert(pM != NULL);
-# ifdef DO_HAVE_ATOMICS
+# ifdef HAVE_ATOMIC_BUILTINS
ATOMIC_INC(pM->iRefCount);
# else
MsgLock(pM);