[svn-commits] russell: trunk r105144 - in /trunk: ./ include/asterisk/ main/ utils/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 28 16:39:27 CST 2008


Author: russell
Date: Thu Feb 28 16:39:26 2008
New Revision: 105144

URL: http://svn.digium.com/view/asterisk?view=rev&rev=105144
Log:
Merged revisions 105116 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r105116 | russell | 2008-02-28 16:23:05 -0600 (Thu, 28 Feb 2008) | 8 lines

Fix a bug in the lock tracking code that was discovered by mmichelson.  The issue
is that if the lock history array was full, then the functions to mark a lock as
acquired or not would adjust the stats for whatever lock is at the end of the array,
which may not be itself.  So, do a sanity check to make sure that we're updating
lock info for the proper lock.

(This explains the bizarre stats on lock #63 in BE-396, thanks Mark!)

........

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/lock.h
    trunk/main/utils.c
    trunk/utils/check_expr.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/lock.h?view=diff&rev=105144&r1=105143&r2=105144
==============================================================================
--- trunk/include/asterisk/lock.h (original)
+++ trunk/include/asterisk/lock.h Thu Feb 28 16:39:26 2008
@@ -154,12 +154,12 @@
 /*!
  * \brief Mark the last lock as acquired
  */
-void ast_mark_lock_acquired(void);
+void ast_mark_lock_acquired(void *lock_addr);
 
 /*!
  * \brief Mark the last lock as failed (trylock)
  */
-void ast_mark_lock_failed(void);
+void ast_mark_lock_failed(void *lock_addr);
 
 /*!
  * \brief remove lock info for the current thread
@@ -378,7 +378,7 @@
 		}
 		ast_reentrancy_unlock(t);
 		if (t->track)
-			ast_mark_lock_acquired();
+			ast_mark_lock_acquired(&t->mutex);
 	} else {
 		if (t->track)
 			ast_remove_lock_info(&t->mutex);
@@ -428,9 +428,9 @@
 		}
 		ast_reentrancy_unlock(t);
 		if (t->track)
-			ast_mark_lock_acquired();
+			ast_mark_lock_acquired(&t->mutex);
 	} else if (t->track) {
-		ast_mark_lock_failed();
+		ast_mark_lock_failed(&t->mutex);
 	}
 
 	return res;
@@ -917,7 +917,7 @@
 	ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_rdlock(lock);
 	if (!res)
-		ast_mark_lock_acquired();
+		ast_mark_lock_acquired(lock);
 	else
 		ast_remove_lock_info(lock);
 	return res;
@@ -948,7 +948,7 @@
 	ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_wrlock(lock);
 	if (!res)
-		ast_mark_lock_acquired();
+		ast_mark_lock_acquired(lock);
 	else
 		ast_remove_lock_info(lock);
 	return res;
@@ -979,7 +979,7 @@
 	ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_tryrdlock(lock);
 	if (!res)
-		ast_mark_lock_acquired();
+		ast_mark_lock_acquired(lock);
 	else
 		ast_remove_lock_info(lock);
 	return res;
@@ -1010,7 +1010,7 @@
 	ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
 	res = pthread_rwlock_trywrlock(lock);
 	if (!res)
-		ast_mark_lock_acquired();
+		ast_mark_lock_acquired(lock);
 	else
 		ast_remove_lock_info(lock);
 	return res;

Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?view=diff&rev=105144&r1=105143&r2=105144
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Thu Feb 28 16:39:26 2008
@@ -633,7 +633,7 @@
 	pthread_mutex_unlock(&lock_info->lock);
 }
 
-void ast_mark_lock_acquired(void)
+void ast_mark_lock_acquired(void *lock_addr)
 {
 	struct thr_lock_info *lock_info;
 
@@ -641,11 +641,13 @@
 		return;
 
 	pthread_mutex_lock(&lock_info->lock);
-	lock_info->locks[lock_info->num_locks - 1].pending = 0;
+	if (lock_info->locks[lock_info->num_locks - 1].lock_addr == lock_addr) {
+		lock_info->locks[lock_info->num_locks - 1].pending = 0;
+	}
 	pthread_mutex_unlock(&lock_info->lock);
 }
 
-void ast_mark_lock_failed(void)
+void ast_mark_lock_failed(void *lock_addr)
 {
 	struct thr_lock_info *lock_info;
 
@@ -653,8 +655,10 @@
 		return;
 
 	pthread_mutex_lock(&lock_info->lock);
-	lock_info->locks[lock_info->num_locks - 1].pending = -1;
-	lock_info->locks[lock_info->num_locks - 1].times_locked--;
+	if (lock_info->locks[lock_info->num_locks - 1].lock_addr == lock_addr) {
+		lock_info->locks[lock_info->num_locks - 1].pending = -1;
+		lock_info->locks[lock_info->num_locks - 1].times_locked--;
+	}
 	pthread_mutex_unlock(&lock_info->lock);
 }
 

Modified: trunk/utils/check_expr.c
URL: http://svn.digium.com/view/asterisk/trunk/utils/check_expr.c?view=diff&rev=105144&r1=105143&r2=105144
==============================================================================
--- trunk/utils/check_expr.c (original)
+++ trunk/utils/check_expr.c Thu Feb 28 16:39:26 2008
@@ -93,8 +93,8 @@
     /* not a lot to do in a standalone w/o threading! */
 }
 
-void ast_mark_lock_acquired(void);
-void ast_mark_lock_acquired(void)
+void ast_mark_lock_acquired(void *);
+void ast_mark_lock_acquired(void *foo)
 {
     /* not a lot to do in a standalone w/o threading! */
 }




More information about the svn-commits mailing list