[asterisk-commits] dvossel: branch 1.8 r325339 - /branches/1.8/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 28 15:31:05 CDT 2011


Author: dvossel
Date: Tue Jun 28 15:31:00 2011
New Revision: 325339

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=325339
Log:
Fixes locking inversion caused by holding sip pvt lock during async_goto.

(closes ASTERISK-17352)

Modified:
    branches/1.8/channels/chan_sip.c

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=325339&r1=325338&r2=325339
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Tue Jun 28 15:31:00 2011
@@ -22885,13 +22885,21 @@
 	}
 	ast_set_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
 
-
-	/* For blind transfers, move the call to the new extensions. For attended transfers on multiple
-	   servers - generate an INVITE with Replaces. Either way, let the dial plan decided  */
-	/* indicate before masquerade so the indication actually makes it to the real channel
-	   when using local channels with MOH passthru */
-	ast_indicate(current.chan2, AST_CONTROL_UNHOLD);
-	res = ast_async_goto(current.chan2, p->refer->refer_to_context, p->refer->refer_to, 1);
+	{
+		char *refer_to_context = ast_strdupa(p->refer->refer_to_context);
+		char *refer_to = ast_strdupa(p->refer->refer_to);
+
+		/* Do not hold the pvt lock during the indicate and async_goto. Those functions
+		 * lock channels which will invalidate locking order if the pvt lock is held.*/
+		ao2_unlock(p);
+		/* For blind transfers, move the call to the new extensions. For attended transfers on multiple
+	   	 * servers - generate an INVITE with Replaces. Either way, let the dial plan decided  */
+		/* indicate before masquerade so the indication actually makes it to the real channel
+	   	 *when using local channels with MOH passthru */
+		ast_indicate(current.chan2, AST_CONTROL_UNHOLD);
+		res = ast_async_goto(current.chan2, refer_to_context, refer_to, 1);
+		ao2_lock(p);
+	}
 
 	if (!res) {
 		ast_manager_event_multichan(EVENT_FLAG_CALL, "Transfer", 2, chans,




More information about the asterisk-commits mailing list