[asterisk-commits] rmudgett: branch rmudgett/bridge_phase r398798 - in /team/rmudgett/bridge_pha...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 10 15:43:04 CDT 2013
Author: rmudgett
Date: Tue Sep 10 15:42:58 2013
New Revision: 398798
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=398798
Log:
Bridge API: Change ast_bridge_join() and ast_bridge_impart() to take a flags parameter.
* 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.
Modified:
team/rmudgett/bridge_phase/apps/app_agent_pool.c
team/rmudgett/bridge_phase/apps/confbridge/conf_chan_announce.c
team/rmudgett/bridge_phase/channels/chan_sip.c
team/rmudgett/bridge_phase/include/asterisk/bridge.h
team/rmudgett/bridge_phase/main/bridge.c
team/rmudgett/bridge_phase/main/bridge_basic.c
team/rmudgett/bridge_phase/main/core_local.c
team/rmudgett/bridge_phase/main/core_unreal.c
team/rmudgett/bridge_phase/main/features.c
team/rmudgett/bridge_phase/res/parking/parking_applications.c
team/rmudgett/bridge_phase/res/parking/parking_bridge_features.c
team/rmudgett/bridge_phase/res/parking/parking_tests.c
team/rmudgett/bridge_phase/res/res_pjsip_refer.c
team/rmudgett/bridge_phase/res/stasis/control.c
team/rmudgett/bridge_phase/tests/test_cdr.c
team/rmudgett/bridge_phase/tests/test_cel.c
Modified: team/rmudgett/bridge_phase/apps/app_agent_pool.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/apps/app_agent_pool.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/apps/app_agent_pool.c (original)
+++ team/rmudgett/bridge_phase/apps/app_agent_pool.c Tue Sep 10 15:42:58 2013
@@ -1509,7 +1509,8 @@
* want to put the agent back into the holding bridge for the
* next caller.
*/
- ast_bridge_join(holding, logged, NULL, &features, NULL, 1);
+ ast_bridge_join(holding, logged, NULL, &features, NULL,
+ AST_BRIDGE_JOIN_PASS_REFERENCE);
if (logged != agent->logged) {
/* This channel is no longer the logged in agent. */
break;
@@ -1890,7 +1891,8 @@
}
ast_indicate(chan, AST_CONTROL_RINGING);
- ast_bridge_join(caller_bridge, chan, NULL, &caller_features, NULL, 1);
+ ast_bridge_join(caller_bridge, chan, NULL, &caller_features, NULL,
+ AST_BRIDGE_JOIN_PASS_REFERENCE);
ast_bridge_features_cleanup(&caller_features);
return -1;
Modified: team/rmudgett/bridge_phase/apps/confbridge/conf_chan_announce.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/apps/confbridge/conf_chan_announce.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/apps/confbridge/conf_chan_announce.c (original)
+++ team/rmudgett/bridge_phase/apps/confbridge/conf_chan_announce.c Tue Sep 10 15:42:58 2013
@@ -196,7 +196,7 @@
ast_set_flag(&features->feature_flags, AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE);
/* Impart the output channel into the bridge */
- if (ast_bridge_impart(p->bridge, chan, NULL, features, 0)) {
+ if (ast_bridge_impart(p->bridge, chan, NULL, features, AST_BRIDGE_IMPART_DEPARTABLE)) {
ast_bridge_features_destroy(features);
ast_channel_unref(chan);
return -1;
Modified: team/rmudgett/bridge_phase/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/channels/chan_sip.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/channels/chan_sip.c (original)
+++ team/rmudgett/bridge_phase/channels/chan_sip.c Tue Sep 10 15:42:58 2013
@@ -24986,7 +24986,7 @@
ast_channel_unlock(replaces_chan);
if (bridge) {
- if (ast_bridge_impart(bridge, c, replaces_chan, NULL, 1)) {
+ if (ast_bridge_impart(bridge, c, replaces_chan, NULL, AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_hangup(c);
}
} else {
Modified: team/rmudgett/bridge_phase/include/asterisk/bridge.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/bridge.h?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/bridge.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/bridge.h Tue Sep 10 15:42:58 2013
@@ -422,6 +422,13 @@
*/
void ast_bridge_notify_masquerade(struct ast_channel *chan);
+enum ast_bridge_join_flags {
+ /*! The bridge reference is being passed by the caller. */
+ AST_BRIDGE_JOIN_PASS_REFERENCE = (1 << 0),
+ /*! The initial bridge join does not cause a COLP exchange. */
+ AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP = (1 << 1),
+};
+
/*!
* \brief Join (blocking) a channel to a bridge
*
@@ -430,7 +437,7 @@
* \param swap Channel to swap out if swapping
* \param features Bridge features structure
* \param tech_args Optional Bridging tech optimization parameters for this channel.
- * \param pass_reference TRUE if the bridge reference is being passed by the caller.
+ * \param flags defined by enum ast_bridge_join_flags.
*
* \note Absolutely _NO_ locks should be held before calling
* this function since it blocks.
@@ -441,7 +448,7 @@
* Example usage:
*
* \code
- * ast_bridge_join(bridge, chan, NULL, NULL, NULL, 0);
+ * ast_bridge_join(bridge, chan, NULL, NULL, NULL, AST_BRIDGE_JOIN_PASS_REFERENCE);
* \endcode
*
* This adds a channel pointed to by the chan pointer to the bridge pointed to by
@@ -460,7 +467,20 @@
struct ast_channel *swap,
struct ast_bridge_features *features,
struct ast_bridge_tech_optimizations *tech_args,
- int pass_reference);
+ enum ast_bridge_join_flags flags);
+
+enum ast_bridge_impart_flags {
+ /*!
+ * \brief The caller wants to reclaim the channel using ast_bridge_depart().
+ *
+ * \note Defined for caller documentation purposes.
+ */
+ AST_BRIDGE_IMPART_DEPARTABLE = (0 << 0),
+ /*! The caller is passing channel control entirely to the bridging system. */
+ AST_BRIDGE_IMPART_INDEPENDENT = (1 << 0),
+ /*! The initial bridge join does not cause a COLP exchange. */
+ AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP = (1 << 1),
+};
/*!
* \brief Impart (non-blocking) a channel onto a bridge
@@ -469,7 +489,7 @@
* \param chan Channel to impart (The channel reference is stolen if impart successful.)
* \param swap Channel to swap out if swapping. NULL if not swapping.
* \param features Bridge features structure.
- * \param independent TRUE if caller does not want to reclaim the channel using ast_bridge_depart().
+ * \param flags defined by enum ast_bridge_impart_flags.
*
* \note The features parameter must be NULL or obtained by
* ast_bridge_features_new(). You must not dereference features
@@ -483,7 +503,7 @@
* Example usage:
*
* \code
- * ast_bridge_impart(bridge, chan, NULL, NULL, 0);
+ * ast_bridge_impart(bridge, chan, NULL, NULL, AST_BRIDGE_IMPART_INDEPENDENT);
* \endcode
*
* \details
@@ -501,20 +521,25 @@
* features structure can be specified in the features
* parameter.
*
- * \note If you impart a channel as not independent you MUST
- * ast_bridge_depart() the channel if this call succeeds. The
- * bridge channel thread is created join-able. The implication
- * is that the channel is special and will not behave like a
- * normal channel.
- *
- * \note If you impart a channel as independent you must not
+ * \note If you impart a channel with
+ * AST_BRIDGE_IMPART_DEPARTABLE you MUST ast_bridge_depart() the
+ * channel if this call succeeds. The bridge channel thread is
+ * created join-able. The implication is that the channel is
+ * special and will not behave like a normal channel.
+ *
+ * \note If you impart a channel with
+ * AST_BRIDGE_IMPART_INDEPENDENT you must not
* ast_bridge_depart() the channel. The bridge channel thread
* is created non-join-able. The channel must be treated as if
* it were placed into the bridge by ast_bridge_join().
* Channels placed into a bridge by ast_bridge_join() are
* removed by a third party using ast_bridge_remove().
*/
-int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, int independent);
+int ast_bridge_impart(struct ast_bridge *bridge,
+ struct ast_channel *chan,
+ struct ast_channel *swap,
+ struct ast_bridge_features *features,
+ enum ast_bridge_impart_flags flags);
/*!
* \brief Depart a channel from a bridge
Modified: team/rmudgett/bridge_phase/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridge.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/main/bridge.c (original)
+++ team/rmudgett/bridge_phase/main/bridge.c Tue Sep 10 15:42:58 2013
@@ -1433,13 +1433,13 @@
struct ast_channel *swap,
struct ast_bridge_features *features,
struct ast_bridge_tech_optimizations *tech_args,
- int pass_reference)
+ enum ast_bridge_join_flags flags)
{
struct ast_bridge_channel *bridge_channel;
int res = 0;
bridge_channel = bridge_channel_internal_alloc(bridge);
- if (pass_reference) {
+ if (flags & AST_BRIDGE_JOIN_PASS_REFERENCE) {
ao2_ref(bridge, -1);
}
if (!bridge_channel) {
@@ -1546,7 +1546,11 @@
return NULL;
}
-int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, int independent)
+int ast_bridge_impart(struct ast_bridge *bridge,
+ struct ast_channel *chan,
+ struct ast_channel *swap,
+ struct ast_bridge_features *features,
+ enum ast_bridge_impart_flags flags)
{
int res = 0;
struct ast_bridge_channel *bridge_channel;
@@ -1585,12 +1589,12 @@
bridge_channel->chan = chan;
bridge_channel->swap = swap;
bridge_channel->features = features;
- bridge_channel->depart_wait = independent ? 0 : 1;
+ bridge_channel->depart_wait = (flags & AST_BRIDGE_IMPART_INDEPENDENT) ? 0 : 1;
bridge_channel->callid = ast_read_threadstorage_callid();
/* Actually create the thread that will handle the channel */
if (!res) {
- if (independent) {
+ if (flags & AST_BRIDGE_IMPART_INDEPENDENT) {
res = ast_pthread_create_detached(&bridge_channel->thread, NULL,
bridge_channel_ind_thread, bridge_channel);
} else {
@@ -2191,7 +2195,8 @@
ast_answer(yanked_chan);
}
ast_channel_ref(yanked_chan);
- if (ast_bridge_impart(bridge, yanked_chan, NULL, features, 1)) {
+ if (ast_bridge_impart(bridge, yanked_chan, NULL, features,
+ AST_BRIDGE_IMPART_INDEPENDENT)) {
/* It is possible for us to yank a channel and have some other
* thread start a PBX on the channl after we yanked it. In particular,
* this can theoretically happen on the ;2 of a Local channel if we
@@ -3638,7 +3643,7 @@
ast_hangup(local);
return AST_BRIDGE_TRANSFER_FAIL;
}
- if (ast_bridge_impart(bridge, local, transferer, NULL, 1)) {
+ if (ast_bridge_impart(bridge, local, transferer, NULL, AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_hangup(local);
return AST_BRIDGE_TRANSFER_FAIL;
}
@@ -3808,7 +3813,7 @@
return AST_BRIDGE_TRANSFER_FAIL;
}
- if (ast_bridge_impart(bridge1, local_chan, chan1, NULL, 1)) {
+ if (ast_bridge_impart(bridge1, local_chan, chan1, NULL, AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_hangup(local_chan);
return AST_BRIDGE_TRANSFER_FAIL;
}
Modified: team/rmudgett/bridge_phase/main/bridge_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridge_basic.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/main/bridge_basic.c (original)
+++ team/rmudgett/bridge_phase/main/bridge_basic.c Tue Sep 10 15:42:58 2013
@@ -2289,7 +2289,8 @@
*/
ast_bridge_features_ds_set(props->recall_target, &props->transferer_features);
ast_channel_ref(props->recall_target);
- if (ast_bridge_impart(props->transferee_bridge, props->recall_target, NULL, NULL, 1)) {
+ if (ast_bridge_impart(props->transferee_bridge, props->recall_target, NULL, NULL,
+ AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_hangup(props->recall_target);
return TRANSFER_FAIL;
}
@@ -2380,7 +2381,8 @@
}
ast_channel_ref(props->recall_target);
- if (ast_bridge_impart(props->transferee_bridge, props->recall_target, NULL, NULL, 1)) {
+ if (ast_bridge_impart(props->transferee_bridge, props->recall_target, NULL, NULL,
+ AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_log(LOG_ERROR, "Unable to place recall target into bridge\n");
ast_hangup(props->recall_target);
return -1;
@@ -3067,7 +3069,8 @@
* choice is to give it a bump
*/
ast_channel_ref(props->transfer_target);
- if (ast_bridge_impart(props->target_bridge, props->transfer_target, NULL, NULL, 1)) {
+ if (ast_bridge_impart(props->target_bridge, props->transfer_target, NULL, NULL,
+ AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_log(LOG_ERROR, "Unable to place transfer target into bridge.\n");
ast_stream_and_wait(bridge_channel->chan, props->failsound, AST_DIGIT_NONE);
ast_bridge_channel_write_unhold(bridge_channel);
Modified: team/rmudgett/bridge_phase/main/core_local.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/core_local.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/main/core_local.c (original)
+++ team/rmudgett/bridge_phase/main/core_local.c Tue Sep 10 15:42:58 2013
@@ -687,7 +687,7 @@
publish_local_bridge_message(p);
ast_answer(chan);
res = ast_bridge_impart(p->action.bridge.join, chan, p->action.bridge.swap,
- p->action.bridge.features, 1);
+ p->action.bridge.features, AST_BRIDGE_IMPART_INDEPENDENT);
ao2_ref(p->action.bridge.join, -1);
p->action.bridge.join = NULL;
ao2_cleanup(p->action.bridge.swap);
Modified: team/rmudgett/bridge_phase/main/core_unreal.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/core_unreal.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/main/core_unreal.c (original)
+++ team/rmudgett/bridge_phase/main/core_unreal.c Tue Sep 10 15:42:58 2013
@@ -745,7 +745,7 @@
ast_set_flag(&features->feature_flags, flags);
/* Impart the semi2 channel into the bridge */
- if (ast_bridge_impart(bridge, chan, NULL, features, 1)) {
+ if (ast_bridge_impart(bridge, chan, NULL, features, AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_bridge_features_destroy(features);
ast_channel_unref(chan);
return -1;
Modified: team/rmudgett/bridge_phase/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/features.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/main/features.c (original)
+++ team/rmudgett/bridge_phase/main/features.c Tue Sep 10 15:42:58 2013
@@ -675,7 +675,7 @@
ast_bridge_basic_set_flags(bridge, flags);
/* Put peer into the bridge */
- if (ast_bridge_impart(bridge, peer, NULL, peer_features, 1)) {
+ if (ast_bridge_impart(bridge, peer, NULL, peer_features, AST_BRIDGE_IMPART_INDEPENDENT)) {
ast_bridge_destroy(bridge, 0);
ast_bridge_features_cleanup(&chan_features);
bridge_failed_peer_goto(chan, peer);
@@ -683,7 +683,8 @@
}
/* Join bridge */
- ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 1);
+ ast_bridge_join(bridge, chan, NULL, &chan_features, NULL,
+ AST_BRIDGE_JOIN_PASS_REFERENCE);
/*
* If the bridge was broken for a hangup that isn't real, then
@@ -1129,7 +1130,8 @@
goto done;
}
- ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 1);
+ ast_bridge_join(bridge, chan, NULL, &chan_features, NULL,
+ AST_BRIDGE_JOIN_PASS_REFERENCE);
ast_bridge_features_cleanup(&chan_features);
Modified: team/rmudgett/bridge_phase/res/parking/parking_applications.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/res/parking/parking_applications.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/res/parking/parking_applications.c (original)
+++ team/rmudgett/bridge_phase/res/parking/parking_applications.c Tue Sep 10 15:42:58 2013
@@ -639,7 +639,8 @@
}
/* 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);
Modified: team/rmudgett/bridge_phase/res/parking/parking_bridge_features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/res/parking/parking_bridge_features.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/res/parking/parking_bridge_features.c (original)
+++ team/rmudgett/bridge_phase/res/parking/parking_bridge_features.c Tue Sep 10 15:42:58 2013
@@ -316,7 +316,8 @@
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_INDEPENDENT)) {
ast_hangup(transfer_chan);
return -1;
}
Modified: team/rmudgett/bridge_phase/res/parking/parking_tests.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/res/parking/parking_tests.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/res/parking/parking_tests.c (original)
+++ team/rmudgett/bridge_phase/res/parking/parking_tests.c Tue Sep 10 15:42:58 2013
@@ -245,9 +245,10 @@
return AST_TEST_FAIL;
}
- ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_alice);
@@ -400,9 +401,10 @@
return AST_TEST_FAIL;
}
- ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ ast_bridge_impart(parking_bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
retrieved_user = parking_lot_retrieve_parked_user(test_lot, 701);
if (!retrieved_user) {
Modified: team/rmudgett/bridge_phase/res/res_pjsip_refer.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/res/res_pjsip_refer.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/res/res_pjsip_refer.c (original)
+++ team/rmudgett/bridge_phase/res/res_pjsip_refer.c Tue Sep 10 15:42:58 2013
@@ -768,7 +768,8 @@
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_INDEPENDENT)) {
response = 500;
}
}
Modified: team/rmudgett/bridge_phase/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/res/stasis/control.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/res/stasis/control.c (original)
+++ team/rmudgett/bridge_phase/res/stasis/control.c Tue Sep 10 15:42:58 2013
@@ -176,7 +176,7 @@
return NULL;
}
- ast_bridge_impart(bridge, new_chan, NULL, NULL, 1);
+ ast_bridge_impart(bridge, new_chan, NULL, NULL, AST_BRIDGE_IMPART_INDEPENDENT);
stasis_app_control_add_channel_to_bridge(control, bridge);
return NULL;
@@ -566,7 +566,7 @@
chan,
NULL, /* swap channel */
NULL, /* features */
- 0); /* independent - false allows us to ast_bridge_depart() */
+ AST_BRIDGE_IMPART_DEPARTABLE);
if (res != 0) {
ast_log(LOG_ERROR, "Error adding channel to bridge\n");
Modified: team/rmudgett/bridge_phase/tests/test_cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/tests/test_cdr.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/tests/test_cdr.c (original)
+++ team/rmudgett/bridge_phase/tests/test_cdr.c Tue Sep 10 15:42:58 2013
@@ -557,9 +557,10 @@
bridge = ast_bridge_basic_new();
ast_test_validate(test, bridge != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
chan_bob = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, "200", NULL, NULL, ast_channel_linkedid(chan_alice), 0, CHANNEL_TECH_NAME "/Bob");
ast_copy_string(bob_expected.linkedid, ast_channel_linkedid(chan_bob), sizeof(bob_expected.linkedid));
@@ -574,11 +575,13 @@
ast_channel_state_set(chan_bob, AST_STATE_UP);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_bob);
ast_bridge_depart(chan_alice);
@@ -685,10 +688,12 @@
bridge = ast_bridge_basic_new();
ast_test_validate(test, bridge != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_bridge_impart(bridge, chan, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_bridge_impart(bridge, chan, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan);
@@ -759,11 +764,13 @@
bridge_one = ast_bridge_basic_new();
ast_test_validate(test, bridge_one != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge_one, chan, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge_one, chan, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan);
@@ -844,15 +851,17 @@
bridge = ast_bridge_basic_new();
ast_test_validate(test, bridge != NULL);
- ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
EMULATE_APP_DATA(chan_bob, 1, "Answer", "");
ast_setstate(chan_bob, AST_STATE_UP);
EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
- ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_alice);
ast_bridge_depart(chan_bob);
@@ -935,13 +944,16 @@
EMULATE_APP_DATA(chan_bob, 1, "Answer", "");
ast_setstate(chan_bob, AST_STATE_UP);
EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_alice);
ast_bridge_depart(chan_bob);
@@ -1054,25 +1066,29 @@
bridge = ast_bridge_basic_new();
ast_test_validate(test, bridge != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
EMULATE_APP_DATA(chan_bob, 1, "Answer", "");
ast_setstate(chan_bob, AST_STATE_UP);
EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
EMULATE_APP_DATA(chan_charlie, 1, "Answer", "");
ast_setstate(chan_charlie, AST_STATE_UP);
EMULATE_APP_DATA(chan_charlie, 2, "Bridge", "");
- ast_bridge_impart(bridge, chan_charlie, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ ast_bridge_impart(bridge, chan_charlie, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_alice);
ast_bridge_depart(chan_bob);
@@ -1667,12 +1683,14 @@
bridge = ast_bridge_basic_new();
ast_test_validate(test, bridge != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
- ast_bridge_impart(bridge, chan_caller, NULL, NULL, 0);
- ast_bridge_impart(bridge, chan_callee, NULL, NULL, 0);
-
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+
+ ast_bridge_impart(bridge, chan_caller, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ ast_bridge_impart(bridge, chan_callee, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_caller);
ast_bridge_depart(chan_callee);
@@ -1742,11 +1760,14 @@
bridge = ast_bridge_basic_new();
ast_test_validate(test, bridge != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_bridge_impart(bridge, chan_callee, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_bridge_impart(bridge, chan_caller, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_bridge_impart(bridge, chan_callee, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_bridge_impart(bridge, chan_caller, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_caller);
ast_bridge_depart(chan_callee);
@@ -1901,15 +1922,20 @@
bridge = ast_bridge_basic_new();
ast_test_validate(test, bridge != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_charlie, NULL, NULL, 0));
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_david, NULL, NULL, 0));
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0));
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0));
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_charlie, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_david, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_test_validate(test, 0 == ast_bridge_depart(chan_alice));
ast_test_validate(test, 0 == ast_bridge_depart(chan_bob));
ast_test_validate(test, 0 == ast_bridge_depart(chan_charlie));
@@ -1991,11 +2017,14 @@
| AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM | AST_BRIDGE_FLAG_TRANSFER_PROHIBITED);
ast_test_validate(test, bridge != NULL);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
- ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
+ ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE);
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_bridge_depart(chan_alice);
ast_bridge_depart(chan_bob);
@@ -2099,7 +2128,8 @@
ast_channel_accountcode_set(chan, "XXX");
/* Wait one second so we get a duration. */
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_cdr_setuserfield(ast_channel_name(chan), "foobar");
ast_test_validate(test, ast_cdr_setvar(ast_channel_name(chan), "test_variable", "record_1") == 0);
@@ -2247,7 +2277,8 @@
CREATE_ALICE_CHANNEL(chan, &caller, &expected);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
/* Disable the CDR */
ast_test_validate(test, ast_cdr_set_property(ast_channel_name(chan), AST_CDR_FLAG_DISABLE) == 0);
@@ -2349,7 +2380,8 @@
ast_copy_string(fork_expected_two.uniqueid, ast_channel_uniqueid(chan), sizeof(fork_expected_two.uniqueid));
ast_copy_string(fork_expected_two.linkedid, ast_channel_linkedid(chan), sizeof(fork_expected_two.linkedid));
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
/* Test blowing away variables */
ast_test_validate(test, ast_cdr_setvar(ast_channel_name(chan), "test_variable", "record_1") == 0);
@@ -2367,7 +2399,8 @@
/* Test keep variables; setting a new answer time */
ast_setstate(chan, AST_STATE_UP);
- while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+ while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+ }
ast_test_validate(test, ast_cdr_setvar(ast_channel_name(chan), "test_variable", "record_2") == 0);
ast_test_validate(test, ast_cdr_getvar(ast_channel_name(chan), "test_variable", varbuffer, sizeof(varbuffer)) == 0);
ast_test_validate(test, strcmp(varbuffer, "record_2") == 0);
Modified: team/rmudgett/bridge_phase/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/tests/test_cel.c?view=diff&rev=398798&r1=398797&r2=398798
==============================================================================
--- team/rmudgett/bridge_phase/tests/test_cel.c (original)
+++ team/rmudgett/bridge_phase/tests/test_cel.c Tue Sep 10 15:42:58 2013
@@ -129,7 +129,7 @@
} while (0)
#define BRIDGE_ENTER(channel, bridge) do { \
- ast_test_validate(test, 0 == ast_bridge_impart(bridge, channel, NULL, NULL, 0)); \
+ ast_test_validate(test, 0 == ast_bridge_impart(bridge, channel, NULL, NULL, AST_BRIDGE_IMPART_DEPARTABLE)); \
do_sleep(); \
BRIDGE_ENTER_EVENT(channel, bridge); \
mid_test_sync(); \
More information about the asterisk-commits
mailing list