aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-21 23:55:26 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-21 23:55:26 +0000
commitdfb51e1416aa60615240da3b222379d7ca340826 (patch)
treed15dec927c987d6d4c75209b63a31012ff9318f6 /channels
parent19cfd3cfc36ff3084365b21f43cd6ac0c1528083 (diff)
Fixing an issue wherein monitoring local channels was not possible. During a channel
masquerade, the monitors on the two channels involved are swapped. In 99% of the cases this results in the desired effect. However, if monitoring a local channel, this caused the monitor which was on the local channel to get moved onto a channel which is immediately hung up after the masquerade has completed. By swapping the monitors prior to the masquerade, we avoid the problem by tricking the masquerade into placing the monitor back onto the channel where we want it. During the investigation of the issue, the channel's monitor was the only thing that was swapped in such a manner which did not make sense to have done. All other variable swapping made sense. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@99426 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_local.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 200b12288..f8a65e470 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -221,6 +221,7 @@ static int local_answer(struct ast_channel *ast)
static void check_bridge(struct local_pvt *p, int isoutbound)
{
+ struct ast_channel_monitor *tmp;
if (ast_test_flag(p, LOCAL_ALREADY_MASQED) || ast_test_flag(p, LOCAL_NO_OPTIMIZATION) || !p->chan || !p->owner || (p->chan->_bridge != ast_bridged_channel(p->chan)))
return;
@@ -238,6 +239,16 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
if (!p->chan->_bridge->_softhangup) {
if (!ast_mutex_trylock(&p->owner->lock)) {
if (!p->owner->_softhangup) {
+ if(p->owner->monitor && !p->chan->_bridge->monitor) {
+ /* If a local channel is being monitored, we don't want a masquerade
+ * to cause the monitor to go away. Since the masquerade swaps the monitors,
+ * pre-swapping the monitors before the masquerade will ensure that the monitor
+ * ends up where it is expected.
+ */
+ tmp = p->owner->monitor;
+ p->owner->monitor = p->chan->_bridge->monitor;
+ p->chan->_bridge->monitor = tmp;
+ }
ast_channel_masquerade(p->owner, p->chan->_bridge);
ast_set_flag(p, LOCAL_ALREADY_MASQED);
}