aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-21 20:29:59 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-21 20:29:59 +0000
commitb5f5dfdec985ebe5a0bd64cd2a786066cea640c4 (patch)
tree5af71cf22cfd05fbdd3712ca2157454fe1499be4 /apps
parentba9b7abab46e5ae063f17bd339cd1956bf5c521e (diff)
Simplify locking code for REDIRECTING interception macro when forwarding a call.
Simplified the locking code by using a local copy of the redirecting party information in app_dial.c:do_forward() and app_queue.c:wait_for_answer() for launching the REDIRECTING interception macro when a call is forwarded. Reduced the lock time of the 'o->chan' and 'in' channels. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@288080 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_dial.c16
-rw-r--r--apps/app_queue.c17
2 files changed, 16 insertions, 17 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 0f7b4880d..51dacb6db 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -852,6 +852,8 @@ static void do_forward(struct chanlist *o,
handle_cause(cause, num);
ast_hangup(original);
} else {
+ struct ast_party_redirecting redirecting;
+
if (single && CAN_EARLY_BRIDGE(peerflags, c, in)) {
ast_rtp_instance_early_bridge_make_compatible(c, in);
}
@@ -895,22 +897,20 @@ static void do_forward(struct chanlist *o,
* deadlock. This is why the handling of c's lock may seem a bit unusual
* here.
*/
+ ast_party_redirecting_init(&redirecting);
+ ast_party_redirecting_copy(&redirecting, &c->redirecting);
ast_channel_unlock(c);
- if (ast_channel_redirecting_macro(c, in, &c->redirecting, 1, 0)) {
- while (ast_channel_trylock(c)) {
- CHANNEL_DEADLOCK_AVOIDANCE(in);
- }
- ast_channel_update_redirecting(in, &c->redirecting, NULL);
- ast_channel_unlock(c);
+ if (ast_channel_redirecting_macro(c, in, &redirecting, 1, 0)) {
+ ast_channel_update_redirecting(in, &redirecting, NULL);
}
+ ast_party_redirecting_free(&redirecting);
+ ast_channel_unlock(in);
ast_clear_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE);
if (ast_test_flag64(peerflags, OPT_CANCEL_TIMEOUT)) {
*to = -1;
}
- ast_channel_unlock(in);
-
if (ast_call(c, stuff, 0)) {
ast_log(LOG_NOTICE, "Forwarding failed to dial '%s/%s'\n",
tech, stuff);
diff --git a/apps/app_queue.c b/apps/app_queue.c
index f44f2152a..e6ce9495b 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3414,6 +3414,8 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
o->stillgoing = 0;
numnochan++;
} else {
+ struct ast_party_redirecting redirecting;
+
ast_channel_lock(o->chan);
while (ast_channel_trylock(in)) {
CHANNEL_DEADLOCK_AVOIDANCE(o->chan);
@@ -3449,27 +3451,24 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
* deadlock. This is why the handling of o->chan's lock may
* seem a bit unusual here.
*/
+ ast_party_redirecting_init(&redirecting);
+ ast_party_redirecting_copy(&redirecting, &o->chan->redirecting);
ast_channel_unlock(o->chan);
- res = ast_channel_redirecting_macro(o->chan, in, &o->chan->redirecting, 1, 0);
- while (ast_channel_trylock(o->chan)) {
- CHANNEL_DEADLOCK_AVOIDANCE(in);
- }
+ res = ast_channel_redirecting_macro(o->chan, in, &redirecting, 1, 0);
if (res) {
- ast_channel_update_redirecting(in, &o->chan->redirecting, NULL);
+ ast_channel_update_redirecting(in, &redirecting, NULL);
}
+ ast_party_redirecting_free(&redirecting);
+ ast_channel_unlock(in);
update_connectedline = 1;
if (ast_call(o->chan, stuff, 0)) {
ast_log(LOG_NOTICE, "Forwarding failed to dial '%s/%s'\n",
tech, stuff);
- ast_channel_unlock(o->chan);
do_hang(o);
numnochan++;
- } else {
- ast_channel_unlock(o->chan);
}
- ast_channel_unlock(in);
}
/* Hangup the original channel now, in case we needed it */
ast_hangup(winner);