[svn-commits] file: branch file/bridging r161530 - /team/file/bridging/main/bridging.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Dec 5 19:17:49 CST 2008
Author: file
Date: Fri Dec 5 19:17:48 2008
New Revision: 161530
URL: http://svn.digium.com/view/asterisk?view=rev&rev=161530
Log:
Make bridge_change_state a bit smarter about when it needs to notify the channel's bridge thread or not and use it wherever the channel's bridge state is changed. This will probably end up becoming a public API call.
Modified:
team/file/bridging/main/bridging.c
Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=161530&r1=161529&r2=161530
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Fri Dec 5 19:17:48 2008
@@ -117,19 +117,20 @@
{
/* Change the state on the bridge channel */
bridge_channel->state = new_state;
-
- /* Poke it's thread using a few different ways */
- pthread_kill(bridge_channel->thread, SIGURG);
/* Poke the bridge technology as well if it wants to know about this */
if (bridge_channel->bridge->technology->poke) {
bridge_channel->bridge->technology->poke(bridge_channel->bridge, bridge_channel);
}
- ast_mutex_lock(&bridge_channel->lock);
- ast_cond_signal(&bridge_channel->cond);
- ast_mutex_unlock(&bridge_channel->lock);
-
+ /* Only poke the channel's thread if it is not us */
+ if (!pthread_equal(pthread_self(), bridge_channel->thread)) {
+ pthread_kill(bridge_channel->thread, SIGURG);
+ ast_mutex_lock(&bridge_channel->lock);
+ ast_cond_signal(&bridge_channel->cond);
+ ast_mutex_unlock(&bridge_channel->lock);
+ }
+
return 0;
}
@@ -743,7 +744,7 @@
hook->callback(bridge, bridge_channel, hook->hook_pvt);
} else {
ast_bridge_dtmf_stream(bridge, dtmf, bridge_channel->chan);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
}
return;
@@ -760,7 +761,7 @@
ast_debug(1, "Playing DTMF stream '%s' out to bridge channel %p\n", dtmf_q, bridge_channel);
ast_dtmf_stream(bridge_channel->chan, NULL, dtmf_q, 250, 0);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return;
}
@@ -1221,14 +1222,14 @@
/* Grab the extension to transfer to */
if (!grab_transfer(bridge_channel->chan, exten, sizeof(exten), bridge_channel->chan->context)) {
ast_stream_and_wait(bridge_channel->chan, "pbx-invalid", AST_DIGIT_ANY);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
/* Get a channel that is the destination we wish to call */
if (!(chan = dial_transfer(bridge_channel->chan, exten, bridge_channel->chan->context))) {
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
@@ -1242,7 +1243,7 @@
static int attended_threeway_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
{
/* This is sort of abusing the depart state but in this instance it is only going to be handled in the below function so it is okay */
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_DEPART;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
return 0;
}
@@ -1253,14 +1254,14 @@
/* It is possible (albeit unlikely) that the bridge channels list may change, so we have to ensure we do all of our magic while locked */
if (!(called_bridge_channel = (AST_LIST_FIRST(&bridge->channels) != bridge_channel ? AST_LIST_FIRST(&bridge->channels) : AST_LIST_LAST(&bridge->channels)))) {
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_END;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
return 0;
}
/* Now we basically eject the other channel from the bridge. This will cause their thread to hang them up, and our own code to consider the transfer failed. */
bridge_change_state(called_bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_END;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
return 0;
}
@@ -1277,14 +1278,14 @@
/* Grab the extension to transfer to */
if (!grab_transfer(bridge_channel->chan, exten, sizeof(exten), bridge_channel->chan->context)) {
ast_stream_and_wait(bridge_channel->chan, "pbx-invalid", AST_DIGIT_ANY);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
/* Get a channel that is the destination we wish to call */
if (!(chan = dial_transfer(bridge_channel->chan, exten, bridge_channel->chan->context))) {
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
@@ -1292,7 +1293,7 @@
if (!(attended_bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_1TO1MIX, 0))) {
ast_hangup(chan);
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
return 0;
}
@@ -1326,7 +1327,7 @@
}
} else {
ast_stream_and_wait(bridge_channel->chan, "beeperr", AST_DIGIT_ANY);
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
}
/* Now that all channels are out of it we can destroy the bridge and the called features structure */
@@ -1340,7 +1341,7 @@
static int feature_hangup(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
{
/* This is very simple, we basically change the state on the bridge channel to end and the core takes care of the rest */
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_END;
+ bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
return 0;
}
More information about the svn-commits
mailing list