diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-05-29 17:35:19 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-05-29 17:35:19 +0000 |
commit | 6e5d843a719d87dc2b3833347fde404c4c228b77 (patch) | |
tree | e50351cd486e0a7298a3de06f70964fe2b1de70b /include/asterisk | |
parent | 9a535bd115207d8e5e721336fde015642c562dd0 (diff) |
Merged revisions 118953 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r118953 | tilghman | 2008-05-29 12:20:16 -0500 (Thu, 29 May 2008) | 3 lines
Add some debugging code that ensures that when we do deadlock avoidance, we
don't lose the information about how a lock was originally acquired.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/lock.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 7f8d00eb6..5a9bc252f 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -220,7 +220,7 @@ static inline void __dump_backtrace(struct ast_bt *bt, int canlog) { char **strings; - size_t i; + ssize_t i; strings = backtrace_symbols(bt->addresses, bt->num_frames); @@ -241,6 +241,38 @@ static inline void __dump_backtrace(struct ast_bt *bt, int canlog) */ void log_show_lock(void *this_lock_addr); +/*! + * \brief retrieve lock info for the specified mutex + * + * this gets called during deadlock avoidance, so that the information may + * be preserved as to what location originally acquired the lock. + */ +#if !defined(LOW_MEMORY) +int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, const char **func, const char **mutex_name); +#else +#define ast_find_lock_info(a,b,c,d,e) -1 +#endif + +/*! + * \brief Unlock a lock briefly + * + * used during deadlock avoidance, to preserve the original location where + * a lock was originally acquired. + */ +#define DEADLOCK_AVOIDANCE(lock) \ + do { \ + const char *__filename, *__func, *__mutex_name; \ + int __lineno; \ + int __res = ast_find_lock_info(lock, &__filename, &__lineno, &__func, &__mutex_name); \ + ast_mutex_unlock(lock); \ + usleep(1); \ + if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \ + ast_mutex_lock(lock); \ + } else { \ + __ast_pthread_mutex_lock(__filename, __lineno, __func, __mutex_name, lock); \ + } \ + } while (0) + static void __attribute__((constructor)) init_empty_mutex(void) { memset(&empty_mutex, 0, sizeof(empty_mutex)); |