diff options
author | Richard Mudgett <rmudgett@digium.com> | 2011-09-26 19:40:12 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2011-09-26 19:40:12 +0000 |
commit | 55b70ae6259a85239d5b983424d9d1b6588d8ab7 (patch) | |
tree | 2d6350156336b0167284d100cb9872f8b2a1ba21 /main | |
parent | 6a0fa4e321a8252000f7abec8bc056f223012cf7 (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 'main')
-rw-r--r-- | main/cel.c | 2 | ||||
-rw-r--r-- | main/logger.c | 5 | ||||
-rw-r--r-- | main/manager.c | 4 | ||||
-rw-r--r-- | main/pbx.c | 18 |
4 files changed, 18 insertions, 11 deletions
diff --git a/main/cel.c b/main/cel.c index 7f5c24f40..ef37a1196 100644 --- a/main/cel.c +++ b/main/cel.c @@ -417,7 +417,7 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event /* first, get the variables from the event */ if (ast_cel_fill_record(event, &record)) { - ast_channel_release(tchan); + ast_channel_unref(tchan); return NULL; } diff --git a/main/logger.c b/main/logger.c index 5027bcbd4..6fc36df00 100644 --- a/main/logger.c +++ b/main/logger.c @@ -651,12 +651,15 @@ static int rotate_file(const char *filename) if (!ast_strlen_zero(exec_after_rotate)) { struct ast_channel *c = ast_dummy_channel_alloc(); char buf[512]; + pbx_builtin_setvar_helper(c, "filename", filename); pbx_substitute_variables_helper(c, exec_after_rotate, buf, sizeof(buf)); + if (c) { + c = ast_channel_unref(c); + } if (ast_safe_system(buf) == -1) { ast_log(LOG_WARNING, "error executing '%s'\n", buf); } - c = ast_channel_release(c); } return res; } diff --git a/main/manager.c b/main/manager.c index c5f973dd7..5320b3f52 100644 --- a/main/manager.c +++ b/main/manager.c @@ -3122,7 +3122,7 @@ static int action_getvar(struct mansession *s, const struct message *m) const char *name = astman_get_header(m, "Channel"); const char *varname = astman_get_header(m, "Variable"); char *varval; - char workspace[1024] = ""; + char workspace[1024]; if (ast_strlen_zero(varname)) { astman_send_error(s, m, "No variable specified"); @@ -3136,12 +3136,12 @@ static int action_getvar(struct mansession *s, const struct message *m) } } + workspace[0] = '\0'; if (varname[strlen(varname) - 1] == ')') { if (!c) { c = ast_dummy_channel_alloc(); if (c) { ast_func_read(c, (char *) varname, workspace, sizeof(workspace)); - c = ast_channel_release(c); } else ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution. Function results may be blank.\n"); } else { diff --git a/main/pbx.c b/main/pbx.c index 7e6e8a122..0e528fd4f 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -3862,7 +3862,7 @@ void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, str cp4 = ast_func_read2(c, finalvars, &substr3, 0) ? NULL : ast_str_buffer(substr3); /* Don't deallocate the varshead that was passed in */ memcpy(&bogus->varshead, &old, sizeof(bogus->varshead)); - ast_channel_release(bogus); + ast_channel_unref(bogus); } else { ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution. Function results may be blank.\n"); } @@ -4061,7 +4061,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace; /* Don't deallocate the varshead that was passed in */ memcpy(&c->varshead, &old, sizeof(c->varshead)); - c = ast_channel_release(c); + c = ast_channel_unref(c); } else { ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution. Function results may be blank.\n"); } @@ -8481,12 +8481,16 @@ static int ast_add_extension2_lockopt(struct ast_context *con, /* If we are adding a hint evalulate in variables and global variables */ if (priority == PRIORITY_HINT && strstr(application, "${") && !strstr(extension, "_")) { struct ast_channel *c = ast_dummy_channel_alloc(); - ast_copy_string(c->exten, extension, sizeof(c->exten)); - ast_copy_string(c->context, con->name, sizeof(c->context)); + if (c) { + ast_copy_string(c->exten, extension, sizeof(c->exten)); + ast_copy_string(c->context, con->name, sizeof(c->context)); + } pbx_substitute_variables_helper(c, application, expand_buf, sizeof(expand_buf)); application = expand_buf; - ast_channel_release(c); + if (c) { + ast_channel_unref(c); + } } length = sizeof(struct ast_exten); @@ -8738,7 +8742,7 @@ static int ast_pbx_outgoing_cdr_failed(void) chan->cdr = ast_cdr_alloc(); if (!chan->cdr) { /* allocation of the cdr failed */ - chan = ast_channel_release(chan); /* free the channel */ + chan = ast_channel_unref(chan); /* free the channel */ return -1; /* return failure */ } @@ -8749,7 +8753,7 @@ static int ast_pbx_outgoing_cdr_failed(void) ast_cdr_failed(chan->cdr); /* set the status to failed */ ast_cdr_detach(chan->cdr); /* post and free the record */ chan->cdr = NULL; - chan = ast_channel_release(chan); /* free the channel */ + chan = ast_channel_unref(chan); /* free the channel */ return 0; /* success */ } |