summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2011-09-26 19:40:12 +0000
committerRichard Mudgett <rmudgett@digium.com>2011-09-26 19:40:12 +0000
commit55b70ae6259a85239d5b983424d9d1b6588d8ab7 (patch)
tree2d6350156336b0167284d100cb9872f8b2a1ba21 /apps
parent6a0fa4e321a8252000f7abec8bc056f223012cf7 (diff)
Merged revisions 337974 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10 ................ r337974 | rmudgett | 2011-09-26 14:35:23 -0500 (Mon, 26 Sep 2011) | 37 lines Merged revisions 337973 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r337973 | rmudgett | 2011-09-26 14:30:39 -0500 (Mon, 26 Sep 2011) | 30 lines Fix deadlock when using dummy channels. Dummy channels created by ast_dummy_channel_alloc() should be destoyed by ast_channel_unref(). Using ast_channel_release() needlessly grabs the channel container lock and can cause a deadlock as a result. * Analyzed use of ast_dummy_channel_alloc() and made use ast_channel_unref() when done with the dummy channel. (Primary reason for the reported deadlock.) * Made app_dial.c:dial_exec_full() not call ast_call() holding any channel locks. Chan_local could not perform deadlock avoidance correctly. (Potential deadlock exposed by this issue. Secondary reason for the reported deadlock since the held lock was part of the deadlock chain.) * Fixed some uses of ast_dummy_channel_alloc() not checking the returned channel pointer for failure. * Fixed some potential chan=NULL pointer usage in func_odbc.c. Protected by testing the bogus_chan value. * Fixed needlessly clearing a 1024 char auto array when setting the first char to zero is enough in manager.c:action_getvar(). (closes issue ASTERISK-18613) Reported by: Thomas Arimont Patches: jira_asterisk_18613_v1.8.patch (license #5621) patch uploaded by rmudgett Tested by: Thomas Arimont ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@337975 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_dial.c2
-rw-r--r--apps/app_minivm.c6
-rw-r--r--apps/app_voicemail.c20
3 files changed, 19 insertions, 9 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 6bea10fc5..a9d1079a1 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -2325,7 +2325,9 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
ast_copy_string(tc->exten, chan->exten, sizeof(tc->exten));
ast_channel_unlock(tc);
+ ast_channel_unlock(chan);
res = ast_call(tc, numsubst, 0); /* Place the call, but don't wait on the answer */
+ ast_channel_lock(chan);
/* Save the info in cdr's that we called them */
if (chan->cdr)
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index 993a5a366..edffd4d3f 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1313,6 +1313,9 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
}
/* Allocate channel used for chanvar substitution */
ast = ast_dummy_channel_alloc();
+ if (!ast) {
+ return -1;
+ }
snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
@@ -1473,8 +1476,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
ast_safe_system(tmp2);
ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : "");
ast_debug(3, "Actual command used: %s\n", tmp2);
- if (ast)
- ast = ast_channel_release(ast);
+ ast = ast_channel_unref(ast);
ast_free(str1);
ast_free(str2);
return 0;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 3c93ae3dc..c9913924e 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -4573,7 +4573,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
} else {
fprintf(p, "From: %s <%s>" ENDL, ast_str_quote(&str2, 0, ast_str_buffer(str1)), who);
}
- ast = ast_channel_release(ast);
+ ast = ast_channel_unref(ast);
} else {
ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
}
@@ -4618,7 +4618,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
} else {
fprintf(p, "Subject: %s" ENDL, ast_str_buffer(str1));
}
- ast = ast_channel_release(ast);
+ ast = ast_channel_unref(ast);
} else {
ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
}
@@ -4704,7 +4704,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
#else
fprintf(p, "%s" ENDL, ast_str_buffer(str1));
#endif
- ast = ast_channel_release(ast);
+ ast = ast_channel_unref(ast);
} else {
ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
}
@@ -4931,7 +4931,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char
} else {
fprintf(p, "From: %s <%s>" ENDL, ast_str_quote(&str2, 0, ast_str_buffer(str1)), who);
}
- ast = ast_channel_release(ast);
+ ast = ast_channel_unref(ast);
} else {
ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
}
@@ -4975,7 +4975,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char
} else {
fprintf(p, "Subject: %s" ENDL, ast_str_buffer(str1));
}
- ast = ast_channel_release(ast);
+ ast = ast_channel_unref(ast);
} else {
ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
}
@@ -4993,7 +4993,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char
prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag);
ast_str_substitute_variables(&str1, 0, ast, pagerbody);
fprintf(p, "%s" ENDL, ast_str_buffer(str1));
- ast = ast_channel_release(ast);
+ ast = ast_channel_unref(ast);
} else {
ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
}
@@ -12689,6 +12689,9 @@ AST_TEST_DEFINE(test_voicemail_msgcount)
!(vmu = find_or_create(testcontext, testmailbox))) {
ast_test_status_update(test, "Cannot create vmu structure\n");
ast_unreplace_sigchld();
+#ifdef IMAP_STORAGE
+ chan = ast_channel_unref(chan);
+#endif
return AST_TEST_FAIL;
}
@@ -12708,6 +12711,9 @@ AST_TEST_DEFINE(test_voicemail_msgcount)
ast_test_status_update(test, "Unable to create test voicemail: %s\n",
syserr > 0 ? strerror(syserr) : "unable to fork()");
ast_unreplace_sigchld();
+#ifdef IMAP_STORAGE
+ chan = ast_channel_unref(chan);
+#endif
return AST_TEST_FAIL;
}
}
@@ -12781,7 +12787,7 @@ AST_TEST_DEFINE(test_voicemail_msgcount)
}
#ifdef IMAP_STORAGE
- chan = ast_channel_release(chan);
+ chan = ast_channel_unref(chan);
#endif
/* And remove test directory */