diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-01-26 22:30:55 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-01-26 22:30:55 +0100 |
commit | ead2c355e3261f98817ccd52bc3644103140e824 (patch) | |
tree | 73841ae761e6719898a8afaa539b0f91cc8d90d0 /runtime/msg.c | |
parent | d5360aa57436bb931c513677bc2cbdb1733a4c6b (diff) | |
download | rsyslog-ead2c355e3261f98817ccd52bc3644103140e824.tar.gz rsyslog-ead2c355e3261f98817ccd52bc3644103140e824.tar.xz rsyslog-ead2c355e3261f98817ccd52bc3644103140e824.zip |
bugfix: unitialized mutex was used in msg.c:getPRI
This was subtle, because getPRI is called as part of the debugging code
(always executed) in syslogd.c:logmsg.
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index 2e2d41ad..02a4cd8a 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -190,6 +190,7 @@ static void MsgPrepareEnqueueLockingCase(msg_t *pThis) * rgerhards, 2008-07-14 */ pthread_mutexattr_destroy(&pThis->mutAttr); + pThis->bDoLock = 1; ENDfunc } @@ -199,14 +200,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) @@ -745,6 +748,7 @@ char *getMSG(msg_t *pM) char *getPRI(msg_t *pM) { int pri; + BEGINfunc if(pM == NULL) return ""; @@ -764,6 +768,7 @@ char *getPRI(msg_t *pM) } MsgUnlock(pM); + ENDfunc return (char*)pM->pszPRI; } |