<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8739">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_refer/chan_sip: Fix INVITE with replaces transfer to ConfBridge<br><br>There is a problem when an INVITE-with-Replaces transfer targets a channel<br>in a ConfBridge.  The transfer will unconditionally swap out the<br>ConfBridge channel.  Unfortunately, the ConfBridge state will not be aware<br>of this change.  Unexpected behavior will happen as a result since<br>ConfBridge channels currently can only be replaced by a masquerade and not<br>normal bridge channel moves.<br><br>* We just need to pretend that the channel isn't in a bridge (like other<br>transfer methods already do) so the transfer channel will masquerade into<br>the ConfBridge channel.<br><br>Change-Id: I209beb0e748fa4f4b92a576f36afa8f495ba4c82<br>---<br>M channels/chan_sip.c<br>M include/asterisk/bridge.h<br>M main/bridge.c<br>M res/res_pjsip_refer.c<br>4 files changed, 17 insertions(+), 12 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/39/8739/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/channels/chan_sip.c b/channels/chan_sip.c<br>index 138021e..3891dad 100644<br>--- a/channels/chan_sip.c<br>+++ b/channels/chan_sip.c<br>@@ -25886,10 +25886,7 @@<br> <br>   ast_raw_answer(c);<br> <br>-        ast_channel_lock(replaces_chan);<br>-     bridge = ast_channel_get_bridge(replaces_chan);<br>-      ast_channel_unlock(replaces_chan);<br>-<br>+        bridge = ast_bridge_transfer_acquire_bridge(replaces_chan);<br>   if (bridge) {<br>                 if (ast_bridge_impart(bridge, c, replaces_chan, NULL,<br>                         AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {<br>diff --git a/include/asterisk/bridge.h b/include/asterisk/bridge.h<br>index 8d5c502..484d9a2 100644<br>--- a/include/asterisk/bridge.h<br>+++ b/include/asterisk/bridge.h<br>@@ -945,6 +945,17 @@<br>  */<br> const char *ast_bridge_video_mode_to_string(enum ast_bridge_video_mode_type video_mode);<br> <br>+/*!<br>+ * \brief Acquire the channel's bridge for transfer purposes.<br>+ * \since 13.21.0<br>+ *<br>+ * \param chan Channel involved in a transfer.<br>+ *<br>+ * \return The bridge the channel is in or NULL if it either isn't<br>+ * in a bridge or should not be considered to be in a bridge.<br>+ */<br>+struct ast_bridge *ast_bridge_transfer_acquire_bridge(struct ast_channel *chan);<br>+<br> enum ast_transfer_result {<br>      /*! The transfer completed successfully */<br>    AST_BRIDGE_TRANSFER_SUCCESS,<br>diff --git a/main/bridge.c b/main/bridge.c<br>index 1109c4b..21645ad 100644<br>--- a/main/bridge.c<br>+++ b/main/bridge.c<br>@@ -4420,7 +4420,7 @@<br>      ao2_iterator_destroy(&iter);<br> }<br> <br>-static struct ast_bridge *acquire_bridge(struct ast_channel *chan)<br>+struct ast_bridge *ast_bridge_transfer_acquire_bridge(struct ast_channel *chan)<br> {<br>    struct ast_bridge *bridge;<br> <br>@@ -4461,7 +4461,7 @@<br>          return AST_BRIDGE_TRANSFER_FAIL;<br>      }<br> <br>- bridge = acquire_bridge(transferer);<br>+ bridge = ast_bridge_transfer_acquire_bridge(transferer);<br>      if (!bridge) {<br>                transfer_result = AST_BRIDGE_TRANSFER_INVALID;<br>                goto publish;<br>@@ -4708,8 +4708,8 @@<br>  const char *app = NULL;<br>       int hangup_target = 0;<br> <br>-    to_transferee_bridge = acquire_bridge(to_transferee);<br>-        to_target_bridge = acquire_bridge(to_transfer_target);<br>+       to_transferee_bridge = ast_bridge_transfer_acquire_bridge(to_transferee);<br>+    to_target_bridge = ast_bridge_transfer_acquire_bridge(to_transfer_target);<br> <br>         transfer_msg = ast_attended_transfer_message_create(1, to_transferee, to_transferee_bridge,<br>                   to_transfer_target, to_target_bridge, NULL, NULL);<br>diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c<br>index 7d892f6..120203c 100644<br>--- a/res/res_pjsip_refer.c<br>+++ b/res/res_pjsip_refer.c<br>@@ -917,10 +917,7 @@<br>         ast_channel_ref(invite->session->channel);<br>      invite->channel = invite->session->channel;<br> <br>-      ast_channel_lock(invite->channel);<br>-        invite->bridge = ast_channel_get_bridge(invite->channel);<br>-      ast_channel_unlock(invite->channel);<br>-<br>+   invite->bridge = ast_bridge_transfer_acquire_bridge(invite->channel);<br>   return 0;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8739">change 8739</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8739"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I209beb0e748fa4f4b92a576f36afa8f495ba4c82 </div>
<div style="display:none"> Gerrit-Change-Number: 8739 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>