[asterisk-commits] alecdavis: trunk r391064 - in /trunk: ./ channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 10 02:35:13 CDT 2013


Author: alecdavis
Date: Mon Jun 10 02:35:06 2013
New Revision: 391064

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391064
Log:
IAX2: fix race condition with nativebridge transfers.

1). When touching the bridgecallno, we need to lock it.

2). stop_stuff() which calls iax2_destroy_helper()
    Assumes the lock on the pvt is already held, when iax2_destroy_helper() is called.
    Thus we need to lock the bridgecallno pvt before we call stop_stuff(iaxs[fr->callno]->bridgecallno);

3).   When evaluating the state of 'callno->transferring' of the current leg,
    we can't change it to READY unless the bridgecallno is locked.
      Why, if we are interrupted by the other call leg before 'transferring = TRANSFER_RELEASED',
    the interrupt will find that it is READY and that the bridgecallno is also READY so Releases the legs.

(closes issue ASTERISK-21409)

Reported by: alecdavis
Tested by: alecdavis
alecdavis (license 585)

Review https://reviewboard.asterisk.org/r/2594/
........

Merged revisions 391062 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 391063 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/channels/chan_iax2.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=391064&r1=391063&r2=391064
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Mon Jun 10 02:35:06 2013
@@ -11215,6 +11215,15 @@
 				}
 				break;
 			case IAX_COMMAND_TXREADY:
+				if (iaxs[fr->callno]->bridgecallno) {
+					while (ast_mutex_trylock(&iaxsl[iaxs[fr->callno]->bridgecallno])) {
+						DEADLOCK_AVOIDANCE(&iaxsl[fr->callno]);
+					}
+					if (!iaxs[fr->callno]) {
+						break;
+					}
+				}
+
 				if ((iaxs[fr->callno]->transferring == TRANSFER_BEGIN) ||
 				    (iaxs[fr->callno]->transferring == TRANSFER_MBEGIN)) {
 					if (iaxs[fr->callno]->transferring == TRANSFER_MBEGIN)
@@ -11262,6 +11271,9 @@
 
 						}
 					}
+				}
+				if (iaxs[fr->callno]->bridgecallno) {
+					ast_mutex_unlock(&iaxsl[iaxs[fr->callno]->bridgecallno]);
 				}
 				break;
 			case IAX_COMMAND_TXREQ:




More information about the asterisk-commits mailing list