[asterisk-commits] russell: branch russell/debug_threads r77840 - /team/russell/debug_threads/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 31 14:08:42 CDT 2007


Author: russell
Date: Tue Jul 31 14:08:41 2007
New Revision: 77840

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77840
Log:
revert some code that wasn't supposed to be committed yet

Modified:
    team/russell/debug_threads/utils.c

Modified: team/russell/debug_threads/utils.c
URL: http://svn.digium.com/view/asterisk/team/russell/debug_threads/utils.c?view=diff&rev=77840&r1=77839&r2=77840
==============================================================================
--- team/russell/debug_threads/utils.c (original)
+++ team/russell/debug_threads/utils.c Tue Jul 31 14:08:41 2007
@@ -502,14 +502,13 @@
 /*! \brief Keep track of which locks a thread holds */
 struct thr_lock_info {
 	pthread_t thread_id;
-	struct {
-		const char *file;
-		int line_num;
-		const char *func;
-		const char *lock_name;
-		void *lock_addr;
-		int times_locked;
-	} locks[AST_MAX_LOCKS];
+	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;
 };
 
@@ -526,62 +525,21 @@
 	const char *func, const char *lock_name, void *lock_addr)
 {
 	struct thr_lock_info *lock_info;
-	int i;
 
 	if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
 		return;
 
-	for (i = 0; i < lock_info->num_locks; i++) {
-		if (lock_info->locks[i].lock_addr == lock_addr) {
-			lock_info->locks[i].times_locked++;
-			return;
-		}
-	}
-
-	if (lock_info->num_locks == AST_MAX_LOCKS) {
-		/* Can't use ast_log here, because it will cause infinite recursion */
-		fprintf(stderr, "XXX ERROR XXX A thread holds more locks than '%d'."
-			"  Increase AST_MAX_LOCKS!\n", AST_MAX_LOCKS);
-		return;
-	}
 	
-	lock_info->locks[i].file = filename;
-	lock_info->locks[i].line_num = line_num;
-	lock_info->locks[i].func = func;
-	lock_info->locks[i].lock_name = lock_name;
-	lock_info->locks[i].lock_addr = lock_addr;
-	lock_info->locks[i].times_locked = 1;
-	lock_info->num_locks++;
 }
 
 void ast_remove_lock_info(void *lock_addr)
 {
 	struct thr_lock_info *lock_info;
-	int i = 0;
 
 	if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
 		return;
 
-	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 :( */
-		return;
-
-	if (lock_info->locks[i].times_locked > 1) {
-		lock_info->locks[i].times_locked--;
-		return;
-	}
-
-	if (i < lock_info->num_locks - 1) {
-		/* Not the last one ... *should* be rare! */
-		memmove(&lock_info->locks[i], &lock_info->locks[i + 1], 
-			(lock_info->num_locks - (i + 1)) * sizeof(lock_info->locks[0]));
-	}
-
-	lock_info->num_locks--;
+
 }
 
 #endif /* DEBUG_THREADS */




More information about the asterisk-commits mailing list