[asterisk-dev] [Code Review] 4354: Bridge core: Pass a ref with the swap channel when joining a bridge.

rmudgett reviewboard at asterisk.org
Mon Jan 19 18:45:01 CST 2015



> On Jan. 19, 2015, 4:24 p.m., Matt Jordan wrote:
> > /branches/13/include/asterisk/bridge.h, lines 460-461
> > <https://reviewboard.asterisk.org/r/4354/diff/1/?file=70757#file70757line460>
> >
> >     Why is it not a good idea for the caller to have their own reference, if they bump the reference to cover the stealing by this function?
> >     
> >     That is, why is the following unsafe:
> >     
> >     swap = ast_channel_find(...);
> >     
> >     ast_channel_ref(swap);
> >     ast_bridge_join(bridge, chan, swap);
> >     
> >

If you do that then the swap channel will linger in the stasis cache until chan comes out of the bridging system; which is likely long after the swap channel has been hung up.  Remember ast_bridge_join() is blocking.


> On Jan. 19, 2015, 4:24 p.m., Matt Jordan wrote:
> > /branches/13/main/bridge.c, line 1601
> > <https://reviewboard.asterisk.org/r/4354/diff/1/?file=70760#file70760line1601>
> >
> >     I don't think the join actually failed here. This should just get called when bridge_channel_internal_join returns, which could occur when the channel was released from the bridge. If I'm wrong, feel free to disregard :-)

If bridge_channel->swap is non-NULL here then the join really did fail and the unref is logged to REF_DEBUG as a result of join failure.  If it is NULL then there is no unref and no corresponding REF_DEBUG log entry.  ao2_cleanup() is a conditional unref.  bridge_channel_internal_join() is blocking so bridge_channel->swap cannot still have a ref if the channel successfully joined.


- rmudgett


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4354/#review14233
-----------------------------------------------------------


On Jan. 19, 2015, 2:31 p.m., rmudgett wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4354/
> -----------------------------------------------------------
> 
> (Updated Jan. 19, 2015, 2:31 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: ASTERISK-24649
>     https://issues.asterisk.org/jira/browse/ASTERISK-24649
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> When code imparts a channel into a bridge to swap with another channel, a ref needs to be held on the swap channel to ensure that it cannot dissapear before finding it in the bridge.
> 
> * The ast_bridge_join() swap channel parameter now always steals a ref for the swap channel.  This is the only change to the bridge framework's public API semantics.
> 
> * bridge_channel_internal_join() now requires the bridge_channel->swap channel to pass in a ref.
> 
> 
> Diffs
> -----
> 
>   /branches/13/main/bridge_channel.c 430794 
>   /branches/13/main/bridge.c 430794 
>   /branches/13/include/asterisk/bridge_internal.h 430794 
>   /branches/13/include/asterisk/bridge_channel_internal.h 430794 
>   /branches/13/include/asterisk/bridge.h 430794 
> 
> Diff: https://reviewboard.asterisk.org/r/4354/diff/
> 
> 
> Testing
> -------
> 
> The testsutite masquerade super test and the --tags=transfer tests still pass.
> 
> 
> Thanks,
> 
> rmudgett
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150120/8d9b9bcb/attachment.html>


More information about the asterisk-dev mailing list