[asterisk-commits] rmudgett: branch group/bridge_construction r386422 - in /team/group/bridge_co...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 24 12:08:33 CDT 2013
Author: rmudgett
Date: Wed Apr 24 12:08:30 2013
New Revision: 386422
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386422
Log:
* Make bridge_channel_push() return a failure status.
* Remove the can_push bridge method. It was not that useful.
Modified:
team/group/bridge_construction/include/asterisk/bridging.h
team/group/bridge_construction/main/bridging.c
Modified: team/group/bridge_construction/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/bridging.h?view=diff&rev=386422&r1=386421&r2=386422
==============================================================================
--- team/group/bridge_construction/include/asterisk/bridging.h (original)
+++ team/group/bridge_construction/include/asterisk/bridging.h Wed Apr 24 12:08:30 2013
@@ -296,19 +296,6 @@
typedef void (*ast_bridge_dissolving_fn)(struct ast_bridge *self);
/*!
- * \brief Can this channel be pushed into the bridge.
- *
- * \param self Bridge to operate upon.
- * \param bridge_channel Bridge channel wanting to push.
- * \param swap Bridge channel to swap places with if not NULL.
- *
- * \note On entry, self is already locked.
- *
- * \retval TRUE if can push this channel into the bridge.
- */
-typedef int (*ast_bridge_can_push_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
-
-/*!
* \brief Push this channel into the bridge.
*
* \param self Bridge to operate upon.
@@ -323,8 +310,8 @@
*
* \note On entry, self is already locked.
*
- * \retval 0 on success
- * \retval -1 on failure
+ * \retval 0 on success.
+ * \retval -1 on failure. The channel did not get pushed.
*/
typedef int (*ast_bridge_push_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
@@ -374,8 +361,6 @@
ast_bridge_destructor_fn destroy;
/*! The bridge is being dissolved. Remove any references to the bridge. */
ast_bridge_dissolving_fn dissolving;
- /*! TRUE if can push the bridge channel into the bridge. */
- ast_bridge_can_push_channel_fn can_push;
/*! Push the bridge channel into the bridge. */
ast_bridge_push_channel_fn push;
/*! Pull the bridge channel from the bridge. */
Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=386422&r1=386421&r2=386422
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Wed Apr 24 12:08:30 2013
@@ -537,36 +537,18 @@
*
* \note On entry, bridge_channel->bridge is already locked.
*
- * \return Nothing
- */
-static void bridge_channel_push(struct ast_bridge_channel *bridge_channel)
+ * \retval 0 on success.
+ * \retval -1 on failure. The channel did not get pushed.
+ */
+static int bridge_channel_push(struct ast_bridge_channel *bridge_channel)
{
struct ast_bridge *bridge = bridge_channel->bridge;
struct ast_bridge_channel *swap;
- int chan_leaving;
ast_assert(!bridge_channel->in_bridge);
swap = find_bridge_channel(bridge, bridge_channel->swap);
bridge_channel->swap = NULL;
-
- chan_leaving = bridge->dissolved
- || !bridge->v_table->can_push(bridge, bridge_channel, swap);
-
- ast_bridge_channel_lock(bridge_channel);
- if (chan_leaving) {
- /*
- * Force out channel being pushed into a dissolved bridge or it
- * is not allowed into the bridge.
- */
- ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
- }
- chan_leaving = bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_WAIT;
- ast_bridge_channel_unlock(bridge_channel);
- if (chan_leaving) {
- /* Don't push a channel in the process of leaving. */
- return;
- }
if (swap) {
ast_debug(1, "Bridge %s: pushing %p(%s) by swapping with %p(%s)\n",
@@ -578,11 +560,12 @@
}
/* Add channel to the bridge */
- if (bridge->v_table->push(bridge, bridge_channel, swap)) {
- ast_log(LOG_ERROR, "Bridge %s: failed to push channel %s into bridge\n",
- bridge->uniqueid, ast_channel_name(bridge_channel->chan));
- ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
- return;
+ if (bridge->dissolved
+ || bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_WAIT
+ || bridge->v_table->push(bridge, bridge_channel, swap)) {
+ ast_debug(1, "Bridge %s: pushing %p(%s) into bridge failed\n",
+ bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan));
+ return -1;
}
bridge_channel->in_bridge = 1;
bridge_channel->just_joined = 1;
@@ -598,6 +581,7 @@
bridge->reconfigured = 1;
ast_bridge_publish_enter(bridge, bridge_channel->chan);
+ return 0;
}
/*! \brief Internal function to handle DTMF from a channel */
@@ -1228,7 +1212,6 @@
|| !v_table->name
|| !v_table->destroy
|| !v_table->dissolving
- || !v_table->can_push
|| !v_table->push
|| !v_table->pull
|| !v_table->notify_masquerade) {
@@ -1325,25 +1308,6 @@
/*!
* \internal
- * \brief ast_bridge base can_push method.
- * \since 12.0.0
- *
- * \param self Bridge to operate upon.
- * \param bridge_channel Bridge channel wanting to push.
- * \param swap Bridge channel to swap places with if not NULL.
- *
- * \note On entry, self is already locked.
- * \note Stub because of nothing to do.
- *
- * \retval TRUE if can push this channel into the bridge.
- */
-static int bridge_base_can_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
-{
- return 1;
-}
-
-/*!
- * \internal
* \brief ast_bridge base push method.
* \since 12.0.0
*
@@ -1400,7 +1364,6 @@
.name = "base",
.destroy = bridge_base_destroy,
.dissolving = bridge_base_dissolving,
- .can_push = bridge_base_can_push,
.push = bridge_base_push,
.pull = bridge_base_pull,
.notify_masquerade = bridge_base_notify_masquerade,
@@ -2337,7 +2300,9 @@
bridge_channel->bridge->callid = ast_read_threadstorage_callid();
}
- bridge_channel_push(bridge_channel);
+ if (bridge_channel_push(bridge_channel)) {
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+ }
bridge_reconfigured(bridge_channel->bridge);
if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
@@ -3120,7 +3085,9 @@
ast_bridge_channel_unlock(bridge_channel);
ao2_ref(src_bridge, -1);
- bridge_channel_push(bridge_channel);
+ if (bridge_channel_push(bridge_channel)) {
+ ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+ }
}
bridge_reconfigured(dst_bridge);
bridge_reconfigured(src_bridge);
More information about the asterisk-commits
mailing list