[asterisk-commits] irroot: branch 10 r330312 - in /branches/10: ./ main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jul 30 10:34:46 CDT 2011


Author: irroot
Date: Sat Jul 30 10:34:41 2011
New Revision: 330312

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=330312
Log:
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/
........

Modified:
    branches/10/   (props changed)
    branches/10/main/channel.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/channel.c?view=diff&rev=330312&r1=330311&r2=330312
==============================================================================
--- branches/10/main/channel.c (original)
+++ branches/10/main/channel.c Sat Jul 30 10:34:41 2011
@@ -6518,8 +6518,16 @@
 	 * 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. */




More information about the asterisk-commits mailing list