summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorGregory Nietsky <gregory@distrotech.co.za>2011-07-30 15:54:23 +0000
committerGregory Nietsky <gregory@distrotech.co.za>2011-07-30 15:54:23 +0000
commit1c0078286e27ef3a50c922d347e29c90ffd90ddb (patch)
tree7887cee1d4dfa3af170b4b9a1df9808ab969ee0f /main/channel.c
parent6a15e95a324bfd4ab6824f4cf9e047d7db684c52 (diff)
Merged revisions 330312 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10 ................ r330312 | irroot | 2011-07-30 17:34:41 +0200 (Sat, 30 Jul 2011) | 15 lines Merged revisions 330311 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r330311 | irroot | 2011-07-30 17:25:16 +0200 (Sat, 30 Jul 2011) | 9 lines prevent double masqurading channels when one is been hung up and deadlock avoidance is used. There is a race condition in ast_do_masquerade / ast_hangup (at least) Reported by me signed off by schmidts with input from David Vossel Review: https://reviewboard.asterisk.org/r/1323/ ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@330313 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/main/channel.c b/main/channel.c
index 902c79d85..f4a04d52f 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -6518,10 +6518,18 @@ int ast_do_masquerade(struct ast_channel *original)
* for deadlock avoidance will not result in any sort of masquerade race condition.
* If masq is called by a different thread while this happens, it will be stuck waiting
* until we unlock the container. */
- while (ast_channel_trylock(clonechan)) {
+ while ((clonechan = original->masq) && ast_channel_trylock(clonechan)) {
CHANNEL_DEADLOCK_AVOIDANCE(original);
}
+ /* recheck if masq has been done the deadlock avoidance above could cause a double masq
+ * this is posible with at least ast_hangup*/
+ if (!original->masq) {
+ ast_channel_unlock(original);
+ ao2_unlock(channels);
+ return 0; /* masq already completed by another thread, or never needed to be done to begin with */
+ }
+
/* Get any transfer masquerade connected line exchange data. */
xfer_ds = ast_channel_datastore_find(original, &xfer_ds_info, NULL);
if (xfer_ds) {