[asterisk-commits] russell: branch russell/debug_threads r77832 - in /team/russell/debug_threads...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 31 11:20:28 CDT 2007


Author: russell
Date: Tue Jul 31 11:20:28 2007
New Revision: 77832

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77832
Log:
Add the hooks for keeping track of lock info for a thread

Modified:
    team/russell/debug_threads/include/asterisk/lock.h
    team/russell/debug_threads/utils.c

Modified: team/russell/debug_threads/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/russell/debug_threads/include/asterisk/lock.h?view=diff&rev=77832&r1=77831&r2=77832
==============================================================================
--- team/russell/debug_threads/include/asterisk/lock.h (original)
+++ team/russell/debug_threads/include/asterisk/lock.h Tue Jul 31 11:20:28 2007
@@ -215,6 +215,11 @@
 #define __AST_MUTEX_DEFINE(scope,mutex) \
 	scope ast_mutex_t mutex = AST_MUTEX_INIT_VALUE
 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
+
+void ast_store_lock_info(const char *filename, int line_num, 
+	const char *func, const char *lock_name, void *lock_addr);
+
+void ast_remove_lock_info(void *lock_addr);
 
 static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func,
                                            const char* mutex_name, ast_mutex_t *t)
@@ -256,6 +261,7 @@
 #endif /* DETECT_DEADLOCKS */
 
 	if (!res) {
+		ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex);
 		if (t->reentrancy < AST_MAX_REENTRANCY) {
 			t->file[t->reentrancy] = filename;
 			t->lineno[t->reentrancy] = lineno;
@@ -295,6 +301,7 @@
 #endif /* defined(AST_MUTEX_INIT_W_CONSTRUCTORS) || defined(AST_MUTEX_INIT_ON_FIRST_USE) */
 
 	if (!(res = pthread_mutex_trylock(&t->mutex))) {
+		ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex);
 		if (t->reentrancy < AST_MAX_REENTRANCY) {
 			t->file[t->reentrancy] = filename;
 			t->lineno[t->reentrancy] = lineno;
@@ -345,6 +352,8 @@
 		t->func[t->reentrancy] = NULL;
 		t->thread[t->reentrancy] = 0;
 	}
+
+	ast_remove_lock_info(&t->mutex);
 
 	if ((res = pthread_mutex_unlock(&t->mutex))) {
 		__ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n", 

Modified: team/russell/debug_threads/utils.c
URL: http://svn.digium.com/view/asterisk/team/russell/debug_threads/utils.c?view=diff&rev=77832&r1=77831&r2=77832
==============================================================================
--- team/russell/debug_threads/utils.c (original)
+++ team/russell/debug_threads/utils.c Tue Jul 31 11:20:28 2007
@@ -505,6 +505,10 @@
 	const char *file[AST_MAX_LOCKS];
 	int line_num[AST_MAX_LOCKS];
 	const char *func[AST_MAX_LOCKS];
+	const char *lock_name[AST_MAX_LOCKS];
+	void *lock_addr[AST_MAX_LOCKS];
+	/*! How many times this thread has locked this lock */
+	int times_locked[AST_MAX_LOCKS];
 	unsigned int num_locks;
 };
 
@@ -516,6 +520,27 @@
 }
 
 AST_THREADSTORAGE_CUSTOM(thread_lock_info, NULL, lock_info_destroy);
+
+void ast_store_lock_info(const char *filename, int line_num, 
+	const char *func, const char *lock_name, void *lock_addr)
+{
+	struct thr_lock_info *lock_info;
+
+	if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
+		return;
+
+	
+}
+
+void ast_remove_lock_info(void *lock_addr)
+{
+	struct thr_lock_info *lock_info;
+
+	if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
+		return;
+
+
+}
 
 #endif /* DEBUG_THREADS */
 




More information about the asterisk-commits mailing list