Add lock tracking for rwlocks. Previously, lock.h only had the ability to

hold tracking information for mutexes.  Now, the "core show locks" output
will output information about who is holding a rwlock when a thread is
waiting on it.

(closes issue #11279)
Reported by: ys
Patches:
      trunk_lock_utils.v8.diff uploaded by ys (license 281)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@120064 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2008-06-03 18:26:51 +00:00
parent 95a05794cf
commit 51051ce949
5 changed files with 580 additions and 306 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4988,7 +4988,7 @@ int __ast_channel_unlock(struct ast_channel *chan, const char *filename, int lin
if (option_debug > 2) {
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock_dont_use.reentrancy))
if ((count = chan->lock_dont_use.track.reentrancy))
ast_debug(3, ":::=== Still have %d locks (recursive)\n", count);
#endif
if (!res)
@ -5022,7 +5022,7 @@ int __ast_channel_lock(struct ast_channel *chan, const char *filename, int linen
if (option_debug > 3) {
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock_dont_use.reentrancy))
if ((count = chan->lock_dont_use.track.reentrancy))
ast_debug(4, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
@ -5054,7 +5054,7 @@ int __ast_channel_trylock(struct ast_channel *chan, const char *filename, int li
if (option_debug > 2) {
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock_dont_use.reentrancy))
if ((count = chan->lock_dont_use.track.reentrancy))
ast_debug(3, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)

View File

@ -790,6 +790,7 @@ static void append_lock_information(struct ast_str **str, struct thr_lock_info *
{
int j;
ast_mutex_t *lock;
struct ast_lock_track *lt;
ast_str_append(str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n",
lock_info->locks[i].pending > 0 ? "Waiting for " :
@ -812,13 +813,13 @@ static void append_lock_information(struct ast_str **str, struct thr_lock_info *
return;
lock = lock_info->locks[i].lock_addr;
ast_reentrancy_lock(lock);
for (j = 0; *str && j < lock->reentrancy; j++) {
lt = &lock->track;
ast_reentrancy_lock(lt);
for (j = 0; *str && j < lt->reentrancy; j++) {
ast_str_append(str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n",
lock->file[j], lock->lineno[j], lock->func[j]);
lt->file[j], lt->lineno[j], lt->func[j]);
}
ast_reentrancy_unlock(lock);
ast_reentrancy_unlock(lt);
}

View File

@ -587,6 +587,12 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
{
}
int ast_bt_get_addresses(struct ast_bt *bt)
{
return 0;
}
#else
void ast_remove_lock_info(void *lock_addr)
{

View File

@ -714,6 +714,12 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
{
}
int ast_bt_get_addresses(struct ast_bt *bt)
{
return 0;
}
#else
void ast_remove_lock_info(void *lock_addr)
{