mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Restore Dial, Queue, and FollowMe 'I' option support.
The Dial, Queue, and FollowMe applications need to inhibit the bridging initial connected line exchange in order to support the 'I' option. * Replaced the pass_reference flag on ast_bridge_join() with a flags parameter to pass other flags defined by enum ast_bridge_join_flags. * Replaced the independent flag on ast_bridge_impart() with a flags parameter to pass other flags defined by enum ast_bridge_impart_flags. * Since the Dial, Queue, and FollowMe applications are now the only callers of ast_bridge_call() and ast_bridge_call_with_flags(), changed the calling contract to require the initial COLP exchange to already have been done by the caller. * Made all callers of ast_bridge_impart() check the return value. It is important. As a precaution, I also made the compiler complain now if it is not checked. * Did some cleanup in parking_tests.c as a result of checking the ast_bridge_impart() return value. An independent, but associated change is: * Reduce stack usage in ast_indicate_data() and add a dropping redundant connected line verbose message. (closes issue ASTERISK-22072) Reported by: Joshua Colp Review: https://reviewboard.asterisk.org/r/2845/ ........ Merged revisions 399136 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399138 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -639,7 +639,8 @@ static int parked_call_app_exec(struct ast_channel *chan, const char *data)
|
||||
}
|
||||
|
||||
/* Now we should try to join the new bridge ourselves... */
|
||||
ast_bridge_join(retrieval_bridge, chan, NULL, &chan_features, NULL, 1);
|
||||
ast_bridge_join(retrieval_bridge, chan, NULL, &chan_features, NULL,
|
||||
AST_BRIDGE_JOIN_PASS_REFERENCE);
|
||||
|
||||
ast_bridge_features_cleanup(&chan_features);
|
||||
|
||||
|
@@ -316,7 +316,8 @@ static int parking_blind_transfer_park(struct ast_bridge_channel *bridge_channel
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ast_bridge_impart(bridge_channel->bridge, transfer_chan, NULL, NULL, 1)) {
|
||||
if (ast_bridge_impart(bridge_channel->bridge, transfer_chan, NULL, NULL,
|
||||
AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
|
||||
ast_hangup(transfer_chan);
|
||||
return -1;
|
||||
}
|
||||
|
@@ -82,6 +82,12 @@ static void safe_channel_release(struct ast_channel *chan)
|
||||
ast_channel_release(chan);
|
||||
}
|
||||
|
||||
static void do_sleep(struct timespec *to_sleep)
|
||||
{
|
||||
while ((nanosleep(to_sleep, to_sleep) == -1) && (errno == EINTR)) {
|
||||
}
|
||||
}
|
||||
|
||||
static int fake_fixup(struct ast_channel *clonechan, struct ast_channel *original)
|
||||
{
|
||||
return 0;
|
||||
@@ -99,7 +105,6 @@ static struct parking_lot *generate_test_parking_lot(const char *name, int low_s
|
||||
struct parking_lot *test_lot;
|
||||
|
||||
test_cfg = parking_lot_cfg_create(name);
|
||||
|
||||
if (!test_cfg) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -120,7 +125,6 @@ static struct parking_lot *generate_test_parking_lot(const char *name, int low_s
|
||||
}
|
||||
|
||||
test_lot = parking_lot_build_or_update(test_cfg, 1);
|
||||
|
||||
if (!test_lot) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -195,7 +199,6 @@ AST_TEST_DEFINE(park_call)
|
||||
RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
|
||||
RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
|
||||
|
||||
struct ast_bridge_features chan_features;
|
||||
struct timespec to_sleep = {1, 0};
|
||||
|
||||
switch (cmd) {
|
||||
@@ -219,7 +222,6 @@ AST_TEST_DEFINE(park_call)
|
||||
}
|
||||
|
||||
chan_alice = create_alice_channel();
|
||||
|
||||
if (!chan_alice) {
|
||||
ast_test_status_update(test, "Failed to create test channel to park. Test failed.\n");
|
||||
dispose_test_lot(test_lot, 1);
|
||||
@@ -227,27 +229,23 @@ AST_TEST_DEFINE(park_call)
|
||||
}
|
||||
|
||||
ast_channel_state_set(chan_alice, AST_STATE_UP);
|
||||
|
||||
pbx_builtin_setvar_helper(chan_alice, "BLINDTRANSFER", ast_channel_name(chan_alice));
|
||||
|
||||
parking_bridge = park_application_setup(chan_alice, chan_alice, TEST_LOT_NAME, NULL);
|
||||
|
||||
if (!parking_bridge) {
|
||||
ast_test_status_update(test, "Failed to get the parking bridge for '%s'. Test failed.\n", TEST_LOT_NAME);
|
||||
dispose_test_lot(test_lot, 1);
|
||||
return AST_TEST_FAIL;
|
||||
}
|
||||
|
||||
if (ast_bridge_features_init(&chan_features)) {
|
||||
ast_bridge_features_cleanup(&chan_features);
|
||||
ast_test_status_update(test, "Failed to initialize bridge features. Test failed.\n");
|
||||
if (ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL,
|
||||
AST_BRIDGE_IMPART_CHAN_DEPARTABLE)) {
|
||||
ast_test_status_update(test, "Failed to impart alice into parking lot. Test failed.\n");
|
||||
dispose_test_lot(test_lot, 1);
|
||||
return AST_TEST_FAIL;
|
||||
}
|
||||
|
||||
ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL, 0);
|
||||
|
||||
while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
|
||||
do_sleep(&to_sleep);
|
||||
|
||||
ast_bridge_depart(chan_alice);
|
||||
|
||||
@@ -255,6 +253,7 @@ AST_TEST_DEFINE(park_call)
|
||||
|
||||
if (dispose_test_lot(test_lot, 1)) {
|
||||
ast_test_status_update(test, "Found parking lot in container after attempted removal. Test failed.\n");
|
||||
return AST_TEST_FAIL;
|
||||
}
|
||||
|
||||
return AST_TEST_PASS;
|
||||
@@ -353,8 +352,6 @@ AST_TEST_DEFINE(retrieve_call)
|
||||
.resolution = PARK_ANSWERED,
|
||||
};
|
||||
|
||||
struct ast_bridge_features chan_features;
|
||||
|
||||
switch (cmd) {
|
||||
case TEST_INIT:
|
||||
info->name = "park_retrieve";
|
||||
@@ -383,7 +380,6 @@ AST_TEST_DEFINE(retrieve_call)
|
||||
}
|
||||
|
||||
ast_channel_state_set(chan_alice, AST_STATE_UP);
|
||||
|
||||
pbx_builtin_setvar_helper(chan_alice, "BLINDTRANSFER", ast_channel_name(chan_alice));
|
||||
|
||||
parking_bridge = park_application_setup(chan_alice, chan_alice, TEST_LOT_NAME, NULL);
|
||||
@@ -393,26 +389,23 @@ AST_TEST_DEFINE(retrieve_call)
|
||||
return AST_TEST_FAIL;
|
||||
}
|
||||
|
||||
if (ast_bridge_features_init(&chan_features)) {
|
||||
ast_bridge_features_cleanup(&chan_features);
|
||||
ast_test_status_update(test, "Failed to initialize bridge features. Test failed.\n");
|
||||
if (ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL,
|
||||
AST_BRIDGE_IMPART_CHAN_DEPARTABLE)) {
|
||||
ast_test_status_update(test, "Failed to impart alice into parking lot. Test failed.\n");
|
||||
dispose_test_lot(test_lot, 1);
|
||||
return AST_TEST_FAIL;
|
||||
}
|
||||
|
||||
ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL, 0);
|
||||
|
||||
while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
|
||||
do_sleep(&to_sleep);
|
||||
|
||||
retrieved_user = parking_lot_retrieve_parked_user(test_lot, 701);
|
||||
if (!retrieved_user) {
|
||||
ast_test_status_update(test, "Failed to retrieve the parked user from the expected parking space. Test failed.\n");
|
||||
|
||||
failure = 1;
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
ast_test_status_update(test, "Successfully retrieved parked user from the parking lot. Validating user data. Test failed.\n");
|
||||
ast_test_status_update(test, "Successfully retrieved parked user from the parking lot. Validating user data.\n");
|
||||
|
||||
if (!parked_users_match(retrieved_user, &expected_user, test)) {
|
||||
ast_test_status_update(test, "Parked user validation failed\n");
|
||||
|
@@ -768,7 +768,8 @@ static int refer_incoming_invite_request(struct ast_sip_session *session, struct
|
||||
response = 500;
|
||||
}
|
||||
} else {
|
||||
if (ast_bridge_impart(invite.bridge, session->channel, invite.channel, NULL, 1)) {
|
||||
if (ast_bridge_impart(invite.bridge, session->channel, invite.channel, NULL,
|
||||
AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
|
||||
response = 500;
|
||||
}
|
||||
}
|
||||
|
@@ -117,7 +117,6 @@ static struct stasis_app_command *exec_command(
|
||||
command_fn = command_fn ? : noop_cb;
|
||||
|
||||
command = command_create(command_fn, data);
|
||||
|
||||
if (!command) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -166,7 +165,6 @@ static void *app_control_dial(struct stasis_app_control *control,
|
||||
ast_dial_set_global_timeout(dial, dial_data->timeout);
|
||||
|
||||
res = ast_dial_run(dial, NULL, 0);
|
||||
|
||||
if (res != AST_DIAL_RESULT_ANSWERED || !(new_chan = ast_dial_answered_steal(dial))) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -176,8 +174,12 @@ static void *app_control_dial(struct stasis_app_control *control,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ast_bridge_impart(bridge, new_chan, NULL, NULL, 1);
|
||||
stasis_app_control_add_channel_to_bridge(control, bridge);
|
||||
if (ast_bridge_impart(bridge, new_chan, NULL, NULL,
|
||||
AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
|
||||
ast_hangup(new_chan);
|
||||
} else {
|
||||
stasis_app_control_add_channel_to_bridge(control, bridge);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -566,8 +568,7 @@ static void *app_control_add_channel_to_bridge(
|
||||
chan,
|
||||
NULL, /* swap channel */
|
||||
NULL, /* features */
|
||||
0); /* independent - false allows us to ast_bridge_depart() */
|
||||
|
||||
AST_BRIDGE_IMPART_CHAN_DEPARTABLE);
|
||||
if (res != 0) {
|
||||
ast_log(LOG_ERROR, "Error adding channel to bridge\n");
|
||||
ast_channel_pbx_set(chan, control->pbx);
|
||||
|
Reference in New Issue
Block a user