summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2009-02-10 01:52:22 +0100
committerMichael Biebl <biebl@debian.org>2009-02-10 01:52:22 +0100
commitc84d74c258d54713cadf8dfbeff10fcb4d91624f (patch)
tree31800ce67d76cf7254cb924cb8d08193040e83c5 /runtime
parenta9a14cc4ca04738ea56eee92c98a63829bdbd438 (diff)
downloadrsyslog-c84d74c258d54713cadf8dfbeff10fcb4d91624f.tar.gz
Imported Upstream version 3.20.4upstream/3.20.4
Diffstat (limited to 'runtime')
-rw-r--r--runtime/Makefile.in2
-rw-r--r--runtime/msg.c26
-rw-r--r--runtime/msg.h1
3 files changed, 13 insertions, 16 deletions
diff --git a/runtime/Makefile.in b/runtime/Makefile.in
index c82d6b2..b7a22f9 100644
--- a/runtime/Makefile.in
+++ b/runtime/Makefile.in
@@ -224,8 +224,6 @@ PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
RELP_CFLAGS = @RELP_CFLAGS@
RELP_LIBS = @RELP_LIBS@
-RFC3195_CFLAGS = @RFC3195_CFLAGS@
-RFC3195_LIBS = @RFC3195_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
diff --git a/runtime/msg.c b/runtime/msg.c
index c8dbf2c..d02b0a0 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -188,6 +188,7 @@ static void MsgPrepareEnqueueLockingCase(msg_t *pThis)
* rgerhards, 2008-07-14
*/
pthread_mutexattr_destroy(&pThis->mutAttr);
+ pThis->bDoLock = 1;
ENDfunc
}
@@ -197,14 +198,16 @@ static void MsgLockLockingCase(msg_t *pThis)
{
/* DEV debug only! dbgprintf("MsgLock(0x%lx)\n", (unsigned long) pThis); */
assert(pThis != NULL);
- pthread_mutex_lock(&pThis->mut);
+ if(pThis->bDoLock == 1) /* TODO: this is a testing hack, we should find a way with better performance! -- rgerhards, 2009-01-27 */
+ pthread_mutex_lock(&pThis->mut);
}
static void MsgUnlockLockingCase(msg_t *pThis)
{
/* DEV debug only! dbgprintf("MsgUnlock(0x%lx)\n", (unsigned long) pThis); */
assert(pThis != NULL);
- pthread_mutex_unlock(&pThis->mut);
+ if(pThis->bDoLock == 1) /* TODO: this is a testing hack, we should find a way with better performance! -- rgerhards, 2009-01-27 */
+ pthread_mutex_unlock(&pThis->mut);
}
/* delete the mutex object on message destruction (locking case)
@@ -271,11 +274,8 @@ 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
- currRefCount = --pThis->iRefCount;
-# endif
+ MsgLock(pThis);
+ currRefCount = --pThis->iRefCount;
if(currRefCount == 0)
{
/* DEV Debugging Only! dbgprintf("msgDestruct\t0x%lx, RefCount now 0, doing DESTROY\n", (unsigned long)pThis); */
@@ -333,8 +333,10 @@ CODESTARTobjDestruct(msg)
rsCStrDestruct(&pThis->pCSPROCID);
if(pThis->pCSMSGID != NULL)
rsCStrDestruct(&pThis->pCSMSGID);
+ MsgUnlock(pThis);
funcDeleteMutex(pThis);
} else {
+ MsgUnlock(pThis);
pThis = NULL; /* tell framework not to destructing the object! */
}
ENDobjDestruct(msg)
@@ -478,13 +480,9 @@ finalize_it:
msg_t *MsgAddRef(msg_t *pM)
{
assert(pM != NULL);
-# ifdef DO_HAVE_ATOMICS
- ATOMIC_INC(pM->iRefCount);
-# else
- MsgLock(pM);
- pM->iRefCount++;
- MsgUnlock(pM);
-# endif
+ MsgLock(pM);
+ pM->iRefCount++;
+ MsgUnlock(pM);
/* DEV debugging only! dbgprintf("MsgAddRef\t0x%x done, Ref now: %d\n", (int)pM, pM->iRefCount);*/
return(pM);
}
diff --git a/runtime/msg.h b/runtime/msg.h
index c428237..fadbb48 100644
--- a/runtime/msg.h
+++ b/runtime/msg.h
@@ -51,6 +51,7 @@
struct msg {
BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */
pthread_mutexattr_t mutAttr;
+short bDoLock; /* use the mutex? */
pthread_mutex_t mut;
int iRefCount; /* reference counter (0 = unused) */
short bParseHOSTNAME; /* should the hostname be parsed from the message? */