diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-09-26 18:40:39 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-09-26 18:40:39 +0200 |
commit | 16970aad2e6d4e69fb9fdb13b392ba6a51dea900 (patch) | |
tree | 2283eafa6d960a8fc2dc7de0317fd2a905cb83d1 /runtime/debug.c | |
parent | 96f312f94f127b7bc9a39e5822afdf28a5b2286c (diff) | |
parent | 92c2e09d19bef9dd10d2e85a663925124d6e00e4 (diff) | |
download | rsyslog-16970aad2e6d4e69fb9fdb13b392ba6a51dea900.tar.gz rsyslog-16970aad2e6d4e69fb9fdb13b392ba6a51dea900.tar.bz2 rsyslog-16970aad2e6d4e69fb9fdb13b392ba6a51dea900.zip |
Merge branch 'helgrind' into perf
Diffstat (limited to 'runtime/debug.c')
-rw-r--r-- | runtime/debug.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/runtime/debug.c b/runtime/debug.c index 987a648a..102d5d0f 100644 --- a/runtime/debug.c +++ b/runtime/debug.c @@ -773,6 +773,17 @@ dbgprint(obj_t *pObj, char *pszMsg, size_t lenMsg) char pszWriteBuf[1024]; size_t lenWriteBuf; struct timespec t; + uchar *pszObjName = NULL; + + /* we must get the object name before we lock the mutex, because the object + * potentially calls back into us. If we locked the mutex, we would deadlock + * ourselfs. On the other hand, the GetName call needs not to be protected, as + * this thread has a valid reference. If such an object is deleted by another + * thread, we are in much more trouble than just for dbgprint(). -- rgerhards, 2008-09-26 + */ + if(pObj != NULL) { + pszObjName = obj.GetName(pObj); + } pthread_mutex_lock(&mutdbgprint); pthread_cleanup_push(dbgMutexCancelCleanupHdlr, &mutdbgprint); @@ -813,8 +824,8 @@ dbgprint(obj_t *pObj, char *pszMsg, size_t lenMsg) if(stddbg != -1) write(stddbg, pszWriteBuf, lenWriteBuf); if(altdbg != -1) write(altdbg, pszWriteBuf, lenWriteBuf); /* print object name header if we have an object */ - if(pObj != NULL) { - lenWriteBuf = snprintf(pszWriteBuf, sizeof(pszWriteBuf), "%s: ", obj.GetName(pObj)); + if(pszObjName != NULL) { + lenWriteBuf = snprintf(pszWriteBuf, sizeof(pszWriteBuf), "%s: ", pszObjName); if(stddbg != -1) write(stddbg, pszWriteBuf, lenWriteBuf); if(altdbg != -1) write(altdbg, pszWriteBuf, lenWriteBuf); } |