mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 00:24:05 +00:00
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
This commit is contained in:
@@ -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));
|
||||
|
Reference in New Issue
Block a user