From b46ad8b190b230ab097847075c07303deb6acfa9 Mon Sep 17 00:00:00 2001 From: Steve Murphy Date: Wed, 16 Jul 2008 23:53:02 +0000 Subject: [PATCH] (closes issue #13089) Reported by: murf Most of this bug was already fixed by Tilghman before I opened it; Many thanks to Tilghman for his fix in svn version 125794. That fix cleared up some of the fields in the lock_info. This commit changes the address that is stored for the lock in the lock_info struct, so that it is the same as that passed into the locking macros. This makes searching for a lock_info (as in log_show_lock()) by its lock addr possible. The lock_addr field is infinitely more useful if it is the same as what is 'publicly' available outside the lock_info code. Many thanks to kpfleming, putnopvut, and Russell for their invaluable insights earlier today. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@131570 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/lock.h | 78 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 33af564058..ae81fe46ec 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -501,9 +501,9 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con ast_bt_get_addresses(<->backtrace[lt->reentrancy]); bt = <->backtrace[lt->reentrancy]; ast_reentrancy_unlock(lt); - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex, bt); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); #else - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); #endif } @@ -565,7 +565,7 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con } ast_reentrancy_unlock(lt); if (t->tracking) { - ast_mark_lock_acquired(&t->mutex); + ast_mark_lock_acquired(t); } } else { #ifdef HAVE_BKTR @@ -577,11 +577,11 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con bt = NULL; } if (t->tracking) { - ast_remove_lock_info(&t->mutex, bt); + ast_remove_lock_info(t, bt); } #else if (t->tracking) { - ast_remove_lock_info(&t->mutex); + ast_remove_lock_info(t); } #endif __ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n", @@ -623,9 +623,9 @@ static inline int __ast_pthread_mutex_trylock(const char *filename, int lineno, ast_bt_get_addresses(<->backtrace[lt->reentrancy]); bt = <->backtrace[lt->reentrancy]; ast_reentrancy_unlock(lt); - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex, bt); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); #else - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); #endif } @@ -643,10 +643,10 @@ static inline int __ast_pthread_mutex_trylock(const char *filename, int lineno, } ast_reentrancy_unlock(lt); if (t->tracking) { - ast_mark_lock_acquired(&t->mutex); + ast_mark_lock_acquired(t); } } else if (t->tracking) { - ast_mark_lock_failed(&t->mutex); + ast_mark_lock_failed(t); } return res; @@ -709,9 +709,9 @@ static inline int __ast_pthread_mutex_unlock(const char *filename, int lineno, c if (t->tracking) { #ifdef HAVE_BKTR - ast_remove_lock_info(&t->mutex, bt); + ast_remove_lock_info(t, bt); #else - ast_remove_lock_info(&t->mutex); + ast_remove_lock_info(t); #endif } @@ -806,9 +806,9 @@ static inline int __ast_cond_wait(const char *filename, int lineno, const char * if (t->tracking) { #ifdef HAVE_BKTR - ast_remove_lock_info(&t->mutex, bt); + ast_remove_lock_info(t, bt); #else - ast_remove_lock_info(&t->mutex); + ast_remove_lock_info(t); #endif } @@ -836,9 +836,9 @@ static inline int __ast_cond_wait(const char *filename, int lineno, const char * if (t->tracking) { #ifdef HAVE_BKTR - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex, bt); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); #else - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); #endif } } @@ -903,9 +903,9 @@ static inline int __ast_cond_timedwait(const char *filename, int lineno, const c if (t->tracking) { #ifdef HAVE_BKTR - ast_remove_lock_info(&t->mutex, bt); + ast_remove_lock_info(t, bt); #else - ast_remove_lock_info(&t->mutex); + ast_remove_lock_info(t); #endif } @@ -933,9 +933,9 @@ static inline int __ast_cond_timedwait(const char *filename, int lineno, const c if (t->tracking) { #ifdef HAVE_BKTR - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex, bt); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); #else - ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); #endif } } @@ -1115,9 +1115,9 @@ static inline int _ast_rwlock_unlock(ast_rwlock_t *t, const char *name, if (t->tracking) { #ifdef HAVE_BKTR - ast_remove_lock_info(&t->lock, bt); + ast_remove_lock_info(t, bt); #else - ast_remove_lock_info(&t->lock); + ast_remove_lock_info(t); #endif } @@ -1161,9 +1161,9 @@ static inline int _ast_rwlock_rdlock(ast_rwlock_t *t, const char *name, ast_bt_get_addresses(<->backtrace[lt->reentrancy]); bt = <->backtrace[lt->reentrancy]; ast_reentrancy_unlock(lt); - ast_store_lock_info(AST_RDLOCK, filename, line, func, name, &t->lock, bt); + ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt); #else - ast_store_lock_info(AST_RDLOCK, filename, line, func, name, &t->lock); + ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t); #endif } @@ -1213,7 +1213,7 @@ static inline int _ast_rwlock_rdlock(ast_rwlock_t *t, const char *name, } ast_reentrancy_unlock(lt); if (t->tracking) { - ast_mark_lock_acquired(&t->lock); + ast_mark_lock_acquired(t); } } else { #ifdef HAVE_BKTR @@ -1225,11 +1225,11 @@ static inline int _ast_rwlock_rdlock(ast_rwlock_t *t, const char *name, bt = NULL; } if (t->tracking) { - ast_remove_lock_info(&t->lock, bt); + ast_remove_lock_info(t, bt); } #else if (t->tracking) { - ast_remove_lock_info(&t->lock); + ast_remove_lock_info(t); } #endif __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n", @@ -1270,9 +1270,9 @@ static inline int _ast_rwlock_wrlock(ast_rwlock_t *t, const char *name, ast_bt_get_addresses(<->backtrace[lt->reentrancy]); bt = <->backtrace[lt->reentrancy]; ast_reentrancy_unlock(lt); - ast_store_lock_info(AST_WRLOCK, filename, line, func, name, &t->lock, bt); + ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); #else - ast_store_lock_info(AST_WRLOCK, filename, line, func, name, &t->lock); + ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); #endif } #ifdef DETECT_DEADLOCKS @@ -1321,7 +1321,7 @@ static inline int _ast_rwlock_wrlock(ast_rwlock_t *t, const char *name, } ast_reentrancy_unlock(lt); if (t->tracking) { - ast_mark_lock_acquired(&t->lock); + ast_mark_lock_acquired(t); } } else { #ifdef HAVE_BKTR @@ -1332,11 +1332,11 @@ static inline int _ast_rwlock_wrlock(ast_rwlock_t *t, const char *name, bt = NULL; } if (t->tracking) { - ast_remove_lock_info(&t->lock, bt); + ast_remove_lock_info(t, bt); } #else if (t->tracking) { - ast_remove_lock_info(&t->lock); + ast_remove_lock_info(t); } #endif __ast_mutex_logger("%s line %d (%s): Error obtaining write lock: %s\n", @@ -1378,9 +1378,9 @@ static inline int _ast_rwlock_tryrdlock(ast_rwlock_t *t, const char *name, ast_bt_get_addresses(<->backtrace[lt->reentrancy]); bt = <->backtrace[lt->reentrancy]; ast_reentrancy_unlock(lt); - ast_store_lock_info(AST_RDLOCK, filename, line, func, name, &t->lock, bt); + ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt); #else - ast_store_lock_info(AST_RDLOCK, filename, line, func, name, &t->lock); + ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t); #endif } @@ -1398,10 +1398,10 @@ static inline int _ast_rwlock_tryrdlock(ast_rwlock_t *t, const char *name, } ast_reentrancy_unlock(lt); if (t->tracking) { - ast_mark_lock_acquired(&t->lock); + ast_mark_lock_acquired(t); } } else if (t->tracking) { - ast_mark_lock_failed(&t->lock); + ast_mark_lock_failed(t); } return res; } @@ -1438,9 +1438,9 @@ static inline int _ast_rwlock_trywrlock(ast_rwlock_t *t, const char *name, ast_bt_get_addresses(<->backtrace[lt->reentrancy]); bt = <->backtrace[lt->reentrancy]; ast_reentrancy_unlock(lt); - ast_store_lock_info(AST_WRLOCK, filename, line, func, name, &t->lock, bt); + ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); #else - ast_store_lock_info(AST_WRLOCK, filename, line, func, name, &t->lock); + ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); #endif } @@ -1458,10 +1458,10 @@ static inline int _ast_rwlock_trywrlock(ast_rwlock_t *t, const char *name, } ast_reentrancy_unlock(lt); if (t->tracking) { - ast_mark_lock_acquired(&t->lock); + ast_mark_lock_acquired(t); } } else if (t->tracking) { - ast_mark_lock_failed(&t->lock); + ast_mark_lock_failed(t); } return res; }