From 348ab667baaf7a84747c695262bd20b8cafaf5ce Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Fri, 18 Apr 2014 16:27:31 +0000 Subject: [PATCH] app_dial and app_queue: Make lock the forwarding channel while taking the channel snapshot. * Fixed ast_channel_publish_dial_forward() not locking the forwarded channel when taking the channel snapshot. * Fixed app_dial.c:do_forward() using the wrong channel to get the original call forwarding string. * Removed unnecessary locking when calling ast_channel_publish_dial() and ast_channel_publish_dial_forward() in app_dial and app_queue. Holding channel locks when calling ast_channel_publish_dial_forward() with a forwarded channel could result in pausing the system while the stasis bus completes processsing a forwarded channel subscription. Review: https://reviewboard.asterisk.org/r/3451/ ........ Merged revisions 412579 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@412580 f38db490-d61c-443f-a65b-d21fe96a405b --- apps/app_dial.c | 9 +-------- apps/app_queue.c | 13 ++++--------- main/stasis_channels.c | 2 ++ 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/apps/app_dial.c b/apps/app_dial.c index 3b74346089..61b2c26a09 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1001,16 +1001,9 @@ static void do_forward(struct chanlist *o, struct cause_args *num, c = o->chan = NULL; num->nochan++; } else { - ast_channel_lock_both(c, in); ast_channel_publish_dial(in, c, stuff, NULL); - ast_channel_unlock(in); - ast_channel_unlock(c); - - ast_channel_lock_both(original, in); ast_channel_publish_dial_forward(in, original, c, NULL, "CANCEL", - ast_channel_call_forward(c)); - ast_channel_unlock(in); - ast_channel_unlock(original); + ast_channel_call_forward(original)); /* Hangup the original channel now, in case we needed it */ ast_hangup(original); diff --git a/apps/app_queue.c b/apps/app_queue.c index 4d97db4059..f71ddba05f 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -4671,16 +4671,11 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte numnochan++; } } - ast_channel_lock_both(qe->chan, o->chan); + ast_channel_publish_dial(qe->chan, o->chan, stuff, NULL); - ast_channel_unlock(o->chan); - ast_channel_unlock(qe->chan); - - ast_channel_lock_both(qe->chan, original); - ast_channel_publish_dial_forward(qe->chan, original, o->chan, NULL, "CANCEL", - ast_channel_call_forward(original)); - ast_channel_unlock(original); - ast_channel_unlock(qe->chan); + ast_channel_publish_dial_forward(qe->chan, original, o->chan, NULL, + "CANCEL", ast_channel_call_forward(original)); + /* Hangup the original channel now, in case we needed it */ ast_hangup(winner); continue; diff --git a/main/stasis_channels.c b/main/stasis_channels.c index eefb7a9f8f..3522fb2910 100644 --- a/main/stasis_channels.c +++ b/main/stasis_channels.c @@ -336,7 +336,9 @@ void ast_channel_publish_dial_forward(struct ast_channel *caller, struct ast_cha ast_multi_channel_blob_add_channel(payload, "peer", peer_snapshot); if (forwarded) { + ast_channel_lock(forwarded); forwarded_snapshot = ast_channel_snapshot_create(forwarded); + ast_channel_unlock(forwarded); if (!forwarded_snapshot) { return; }