summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2009-03-27 01:35:56 +0000
committerRussell Bryant <russell@russellbryant.com>2009-03-27 01:35:56 +0000
commit37b5a29dc7b4d85a739b942f617a365dcb4736dc (patch)
treeb9133121a02974e51b0499dc05dabf18d36cc528
parent4e931d87ffe7c773304c0ce37877816ba0281a95 (diff)
Pass more useful information through to lock tracking when DEBUG_THREADS is on.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184512 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--include/asterisk/heap.h13
-rw-r--r--main/heap.c20
2 files changed, 33 insertions, 0 deletions
diff --git a/include/asterisk/heap.h b/include/asterisk/heap.h
index 654ec5e1e..6bf97b4f3 100644
--- a/include/asterisk/heap.h
+++ b/include/asterisk/heap.h
@@ -209,6 +209,8 @@ void *ast_heap_peek(struct ast_heap *h, unsigned int index);
*/
size_t ast_heap_size(struct ast_heap *h);
+#ifndef DEBUG_THREADS
+
/*!
* \brief Write-Lock a heap
*
@@ -247,6 +249,17 @@ int ast_heap_rdlock(struct ast_heap *h);
*/
int ast_heap_unlock(struct ast_heap *h);
+#else /* DEBUG_THREADS */
+
+#define ast_heap_wrlock(h) __ast_heap_wrlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line);
+#define ast_heap_rdlock(h) __ast_heap_rdlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line);
+#define ast_heap_unlock(h) __ast_heap_unlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+int __ast_heap_unlock(struct ast_heap *h, const char *file, const char *func, int line);
+
+#endif /* DEBUG_THREADS */
+
/*!
* \brief Verify that a heap has been properly constructed
*
diff --git a/main/heap.c b/main/heap.c
index e3932d72f..ace5bc832 100644
--- a/main/heap.c
+++ b/main/heap.c
@@ -302,6 +302,8 @@ size_t ast_heap_size(struct ast_heap *h)
return h->cur_len;
}
+#ifndef DEBUG_THREADS
+
int ast_heap_wrlock(struct ast_heap *h)
{
return ast_rwlock_wrlock(&h->lock);
@@ -317,3 +319,21 @@ int ast_heap_unlock(struct ast_heap *h)
return ast_rwlock_unlock(&h->lock);
}
+#else /* DEBUG_THREADS */
+
+int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line)
+{
+ return _ast_rwlock_wrlock(&h->lock, "&h->lock", file, line, func);
+}
+
+int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line)
+{
+ return _ast_rwlock_rdlock(&h->lock, "&h->lock", file, line, func);
+}
+
+int __ast_heap_unlock(struct ast_heap *h, const char *file, const char *func, int line)
+{
+ return _ast_rwlock_unlock(&h->lock, "&h->lock", file, line, func);
+}
+
+#endif /* DEBUG_THREADS */