diff options
author | Russell Bryant <russell@russellbryant.com> | 2007-10-01 21:15:57 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2007-10-01 21:15:57 +0000 |
commit | 9334e72e76656b7f357c37a1a67c02d87ca139fc (patch) | |
tree | d919dcf3145f4b1b0a19c979b0049abf48c99969 /main | |
parent | efaa9cf6076e51a53273f5d2f6589e5f643d315f (diff) |
Merged revisions 84271 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r84271 | russell | 2007-10-01 16:07:06 -0500 (Mon, 01 Oct 2007) | 4 lines
Fulfull a feature request from Qwell on the "core show locks" output. It will
now note the lock type for each lock that a thread holds.
(mutex, rdlock, or wrlock)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@84272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/utils.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/main/utils.c b/main/utils.c index 2b87e2b4a..0038f01fb 100644 --- a/main/utils.c +++ b/main/utils.c @@ -547,6 +547,7 @@ struct thr_lock_info { const char *lock_name; void *lock_addr; int times_locked; + enum ast_lock_type type; /*! This thread is waiting on this lock */ unsigned int pending:1; } locks[AST_MAX_LOCKS]; @@ -592,8 +593,8 @@ static void lock_info_destroy(void *data) */ AST_THREADSTORAGE_CUSTOM(thread_lock_info, NULL, lock_info_destroy); -void ast_store_lock_info(const char *filename, int line_num, - const char *func, const char *lock_name, void *lock_addr) +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 thr_lock_info *lock_info; int i; @@ -625,6 +626,7 @@ void ast_store_lock_info(const char *filename, int line_num, lock_info->locks[i].lock_name = lock_name; lock_info->locks[i].lock_addr = lock_addr; lock_info->locks[i].times_locked = 1; + lock_info->locks[i].type = type; lock_info->locks[i].pending = 1; lock_info->num_locks++; @@ -681,6 +683,20 @@ void ast_remove_lock_info(void *lock_addr) pthread_mutex_unlock(&lock_info->lock); } +static const char *locktype2str(enum ast_lock_type type) +{ + switch (type) { + case AST_MUTEX: + return "MUTEX"; + case AST_RDLOCK: + return "RDLOCK"; + case AST_WRLOCK: + return "WRLOCK"; + } + + return "UNKNOWN"; +} + static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct thr_lock_info *lock_info; @@ -713,9 +729,11 @@ static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_ lock_info->thread_name); pthread_mutex_lock(&lock_info->lock); for (i = 0; i < lock_info->num_locks; i++) { - ast_cli(a->fd, "=== ---> %sLock #%d: %s %d %s %s %p (%d)\n", + ast_cli(a->fd, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", lock_info->locks[i].pending ? "Waiting for " : "", i, - lock_info->locks[i].file, lock_info->locks[i].line_num, + lock_info->locks[i].file, + locktype2str(lock_info->locks[i].type), + lock_info->locks[i].line_num, lock_info->locks[i].func, lock_info->locks[i].lock_name, lock_info->locks[i].lock_addr, lock_info->locks[i].times_locked); |