summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-09-26 18:40:39 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-09-26 18:40:39 +0200
commit16970aad2e6d4e69fb9fdb13b392ba6a51dea900 (patch)
tree2283eafa6d960a8fc2dc7de0317fd2a905cb83d1 /runtime
parent96f312f94f127b7bc9a39e5822afdf28a5b2286c (diff)
parent92c2e09d19bef9dd10d2e85a663925124d6e00e4 (diff)
downloadrsyslog-16970aad2e6d4e69fb9fdb13b392ba6a51dea900.tar.gz
rsyslog-16970aad2e6d4e69fb9fdb13b392ba6a51dea900.tar.xz
rsyslog-16970aad2e6d4e69fb9fdb13b392ba6a51dea900.zip
Merge branch 'helgrind' into perf
Diffstat (limited to 'runtime')
-rw-r--r--runtime/debug.c15
-rw-r--r--runtime/queue.c8
2 files changed, 15 insertions, 8 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);
}
diff --git a/runtime/queue.c b/runtime/queue.c
index c0a37019..3fae4aa7 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -2092,7 +2092,6 @@ queueEnqObj(queue_t *pThis, flowControl_t flowCtlType, void *pUsr)
{
DEFiRet;
int iCancelStateSave;
- int i;
struct timespec t;
ISOBJ_TYPE_assert(pThis, queue);
@@ -2172,13 +2171,10 @@ queueEnqObj(queue_t *pThis, flowControl_t flowCtlType, void *pUsr)
finalize_it:
if(pThis->qType != QUEUETYPE_DIRECT) {
/* make sure at least one worker is running. */
- if(pThis->qType != QUEUETYPE_DIRECT) {
- queueAdviseMaxWorkers(pThis);
- }
+ queueAdviseMaxWorkers(pThis);
+ dbgoprint((obj_t*) pThis, "EnqueueMsg advised worker start\n");
/* and release the mutex */
- i = pthread_cond_signal(&pThis->notEmpty);
d_pthread_mutex_unlock(pThis->mut);
- dbgoprint((obj_t*) pThis, "EnqueueMsg signaled condition (%d)\n", i);
pthread_setcancelstate(iCancelStateSave, NULL);
}