summaryrefslogtreecommitdiff
path: root/main/utils.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-08-15 12:12:26 +0000
committerKinsey Moore <kmoore@digium.com>2013-08-15 12:12:26 +0000
commit3f46d461bf294a7047a370255adaddbc67006723 (patch)
treeebc404815ee3af99d598cf795dffbeecffa15440 /main/utils.c
parente9ac63f9a99d29f1a7c8e966dcb9d187b85900dc (diff)
Fix deadlocks in chan_sip in REFER and BYE handling
This resolves several deadlocks in chan_sip relating to usage of ast_channel_bridge_peer and improves accessibility of lock debugging function calls. Review: https://reviewboard.asterisk.org/r/2756/ (closes issue ASTERISK-22215) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396723 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/utils.c')
-rw-r--r--main/utils.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/main/utils.c b/main/utils.c
index b19148b7d..1f0528556 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -927,7 +927,7 @@ static void append_lock_information(struct ast_str **str, struct thr_lock_info *
which will give a stack trace and continue. -- that aught to do the job!
*/
-void log_show_lock(void *this_lock_addr)
+void ast_log_show_lock(void *this_lock_addr)
{
struct thr_lock_info *lock_info;
struct ast_str *str;
@@ -958,24 +958,12 @@ void log_show_lock(void *this_lock_addr)
}
-static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+struct ast_str *ast_dump_locks(void)
{
struct thr_lock_info *lock_info;
struct ast_str *str;
- if (!(str = ast_str_create(4096)))
- return CLI_FAILURE;
-
- switch (cmd) {
- case CLI_INIT:
- e->command = "core show locks";
- e->usage =
- "Usage: core show locks\n"
- " This command is for lock debugging. It prints out which locks\n"
- "are owned by each active thread.\n";
- return NULL;
-
- case CLI_GENERATE:
+ if (!(str = ast_str_create(4096))) {
return NULL;
}
@@ -988,8 +976,9 @@ static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_
"=== <pending> <lock#> (<file>): <lock type> <line num> <function> <lock name> <lock addr> (times locked)\n"
"===\n", ast_get_version());
- if (!str)
- return CLI_FAILURE;
+ if (!str) {
+ return NULL;
+ }
pthread_mutex_lock(&lock_infos_lock.mutex);
AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) {
@@ -1012,14 +1001,37 @@ static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_
}
pthread_mutex_unlock(&lock_infos_lock.mutex);
- if (!str)
- return CLI_FAILURE;
+ if (!str) {
+ return NULL;
+ }
ast_str_append(&str, 0, "=======================================================================\n"
"\n");
- if (!str)
+ return str;
+}
+
+static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct ast_str *str;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show locks";
+ e->usage =
+ "Usage: core show locks\n"
+ " This command is for lock debugging. It prints out which locks\n"
+ "are owned by each active thread.\n";
+ return NULL;
+
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ str = ast_dump_locks();
+ if (!str) {
return CLI_FAILURE;
+ }
ast_cli(a->fd, "%s", ast_str_buffer(str));