summaryrefslogtreecommitdiff
path: root/res/ari
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2016-07-11 19:07:20 -0600
committerGeorge Joseph <gjoseph@digium.com>2016-07-12 11:16:44 -0600
commit886f2cab232e1dca65a90036aef39eda27443f4e (patch)
treebab3056afea4daaca8e58c0eac384a3b9b0a1e44 /res/ari
parent44f16af7cc9a6bc5203106a81b595997cb31c4fd (diff)
rest_api/channels: Fix multiple issues with create and dial
* We weren't properly subscribing to the channel and it's originator on create. * We weren't doing a publish_dial after calling ast_call on dial. * We weren't calling depart_bridge when a channel left the dial bridge. The first 2 issues were causing events to not be generated and the third was actually causing channels to not get properly destroyed when hung up. Together these 3 issues were causing the new rest_apichannels/create_dial_bridge tests to fail. As a result of the fixes, the cdr state machine had to be slightly tweaked to allow bridge leave events without asserting and the tests themselves had to be updated to account for the channels now cleaning themselves up. Change-Id: Ibf23abf5a62de76e82afb4461af5099c961b97d8
Diffstat (limited to 'res/ari')
-rw-r--r--res/ari/resource_channels.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index bce7c7def..35b757267 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -1776,6 +1776,9 @@ void ast_ari_channels_create(struct ast_variable *headers,
originator = ast_channel_get_by_name(args->originator);
if (originator) {
request_cap = ao2_bump(ast_channel_nativeformats(originator));
+ if (!ast_strlen_zero(args->app)) {
+ stasis_app_subscribe_channel(args->app, originator);
+ }
} else if (!ast_strlen_zero(args->formats)) {
char *format_name;
char *formats_copy = ast_strdupa(args->formats);
@@ -1816,13 +1819,20 @@ void ast_ari_channels_create(struct ast_variable *headers,
chan_data->chan = ast_request(dialtech, request_cap, &assignedids, originator, dialdevice, &cause);
ao2_cleanup(request_cap);
- ast_channel_cleanup(originator);
+
if (!chan_data->chan) {
ast_ari_response_alloc_failed(response);
+ ast_channel_cleanup(originator);
chan_data_destroy(chan_data);
return;
}
+ if (!ast_strlen_zero(args->app)) {
+ stasis_app_subscribe_channel(args->app, chan_data->chan);
+ }
+
+ ast_channel_cleanup(originator);
+
if (save_dialstring(chan_data->chan, stuff)) {
ast_ari_response_alloc_failed(response);
chan_data_destroy(chan_data);