aboutsummaryrefslogtreecommitdiffstats
path: root/main/utils.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-29 17:42:28 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-29 17:42:28 +0000
commit5f08a3ee3a2125e69352c5404d7f57bed9b480f6 (patch)
tree1423c2f41c452512d73905e0542e62bb6c598735 /main/utils.c
parent119443fc3f48cf7d749e58ea9c7d47af6511a3b4 (diff)
Merged revisions 118955,118957 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r118955 | tilghman | 2008-05-29 12:35:19 -0500 (Thu, 29 May 2008) | 11 lines Merged revisions 118953 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r118953 | tilghman | 2008-05-29 12:20:16 -0500 (Thu, 29 May 2008) | 3 lines Add some debugging code that ensures that when we do deadlock avoidance, we don't lose the information about how a lock was originally acquired. ........ ................ r118957 | tilghman | 2008-05-29 12:39:50 -0500 (Thu, 29 May 2008) | 10 lines Merged revisions 118954 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r118954 | tilghman | 2008-05-29 12:33:01 -0500 (Thu, 29 May 2008) | 2 lines Define also when not DEBUG_THREADS ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@118958 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/utils.c')
-rw-r--r--main/utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/main/utils.c b/main/utils.c
index b08296263..c14d4c4b0 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -662,6 +662,34 @@ void ast_mark_lock_failed(void *lock_addr)
pthread_mutex_unlock(&lock_info->lock);
}
+int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, const char **func, const char **mutex_name)
+{
+ struct thr_lock_info *lock_info;
+ int i = 0;
+
+ if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
+ return -1;
+
+ pthread_mutex_lock(&lock_info->lock);
+
+ for (i = lock_info->num_locks - 1; i >= 0; i--) {
+ if (lock_info->locks[i].lock_addr == lock_addr)
+ break;
+ }
+
+ if (i == -1) {
+ /* Lock not found :( */
+ pthread_mutex_unlock(&lock_info->lock);
+ return -1;
+ }
+
+ *filename = lock_info->locks[i].file;
+ *lineno = lock_info->locks[i].line_num;
+ *func = lock_info->locks[i].func;
+ *mutex_name = lock_info->locks[i].lock_name;
+ return 0;
+}
+
void ast_remove_lock_info(void *lock_addr)
{
struct thr_lock_info *lock_info;