Author: bebuild Date: Mon Dec 22 12:28:33 2014 New Revision: 430007 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430007 Log: Prevent possible race condition on dual redirect of channels in the same bridge.
The AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT flag was created to prevent bridges from prematurely acting on orphaned channels in bridges. The problem with the AMI redirect action was that it was setting this flag on channels based on the presence of a PBX, not whether the channel was in a bridge. Whether a channel has a PBX is irrelevant, so the condition has been altered to check if the channel is in a bridge. ASTERISK-24536 #close Reported by Niklas Larsson Review: https://reviewboard.asterisk.org/r/4268 ........ Merged revisions 429741 from http://svn.asterisk.org/svn/asterisk/branches/13 Modified: certified/branches/13.1/ (props changed) certified/branches/13.1/main/manager.c Propchange: certified/branches/13.1/ ------------------------------------------------------------------------------ --- branch-13-merged (original) +++ branch-13-merged Mon Dec 22 12:28:33 2014 @@ -1,1 +1,1 @@ -/branches/13:429153,429175,429196,429206,429407,429409,429433,429477,429497,429540,429571,429739,429761,429829 +/branches/13:429153,429175,429196,429206,429407,429409,429433,429477,429497,429540,429571,429739,429741,429761,429829 Modified: certified/branches/13.1/main/manager.c URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/main/manager.c?view=diff&rev=430007&r1=430006&r2=430007 ============================================================================== --- certified/branches/13.1/main/manager.c (original) +++ certified/branches/13.1/main/manager.c Mon Dec 22 12:28:33 2014 @@ -4527,6 +4527,8 @@ int pi = 0; int pi2 = 0; int res; + int chan1_wait = 0; + int chan2_wait = 0; if (ast_strlen_zero(name)) { astman_send_error(s, m, "Channel not specified"); @@ -4611,16 +4613,20 @@ } /* Dual channel redirect in progress. */ - if (ast_channel_pbx(chan)) { - ast_channel_lock(chan); + ast_channel_lock(chan); + if (ast_channel_is_bridged(chan)) { ast_set_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT); - ast_channel_unlock(chan); - } - if (ast_channel_pbx(chan2)) { - ast_channel_lock(chan2); + chan1_wait = 1; + } + ast_channel_unlock(chan); + + ast_channel_lock(chan2); + if (ast_channel_is_bridged(chan2)) { ast_set_flag(ast_channel_flags(chan2), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT); - ast_channel_unlock(chan2); - } + chan2_wait = 1; + } + ast_channel_unlock(chan2); + res = ast_async_goto(chan, context, exten, pi); if (!res) { if (!ast_strlen_zero(context2)) { @@ -4638,12 +4644,12 @@ } /* Release the bridge wait. */ - if (ast_channel_pbx(chan)) { + if (chan1_wait) { ast_channel_lock(chan); ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT); ast_channel_unlock(chan); } - if (ast_channel_pbx(chan2)) { + if (chan2_wait) { ast_channel_lock(chan2); ast_clear_flag(ast_channel_flags(chan2), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT); ast_channel_unlock(chan2); -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits
