From b4574d2a79929eb84d085c0f0ee17c9cf4759505 Mon Sep 17 00:00:00 2001
From: Brett Bryant <bbryant@digium.com>
Date: Thu, 19 Jun 2008 19:48:26 +0000
Subject: [PATCH] Add errors that report any locks held by threads when they
 are being closed.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@124064 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/utils.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/main/utils.c b/main/utils.c
index b043b6149a..4b9869984c 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -574,11 +574,25 @@ static AST_LIST_HEAD_NOLOCK_STATIC(lock_infos, thr_lock_info);
 static void lock_info_destroy(void *data)
 {
 	struct thr_lock_info *lock_info = data;
+	int i;
 
 	pthread_mutex_lock(&lock_infos_lock.mutex);
 	AST_LIST_REMOVE(&lock_infos, lock_info, entry);
 	pthread_mutex_unlock(&lock_infos_lock.mutex);
 
+
+	for (i = 0; i < lock_info->num_locks; i++) {
+		ast_log(LOG_ERROR, 
+			"Thread '%s' still has a lock! - '%s' (%p) from '%s' in %s:%d!\n", 
+			lock_info->thread_name,
+			lock_info->locks[i].lock_name,
+			lock_info->locks[i].lock_addr,
+			lock_info->locks[i].func,
+			lock_info->locks[i].file,
+			lock_info->locks[i].line_num
+		);
+	}
+
 	pthread_mutex_destroy(&lock_info->lock);
 	if (lock_info->thread_name)
 		free((void *) lock_info->thread_name);
-- 
GitLab