<div>Hi to all,</div><div><br></div>I&#39;m trying to put a simple modification in Asterisk code that sets channel variables after a successful attended transfer. So I modified attempt_transfer() on chan_sip.c but I get a random crash (but can be deduced to be related to the attend transfer). Here is a snippet of what I modified:<div>
<br></div><div><div>if (ast_channel_masquerade(peerb, peerc)) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ast_log(LOG_WARNING, &quot;Failed to masquerade %s into %s\n&quot;, peerb-&gt;name, peerc-&gt;name);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>res = -1;</div><div>} else {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ast_log(LOG_DEBUG, &quot;SIP transfer: Succeeded to masquerade %s into %s\n&quot;, peerc-&gt;name, peerb-&gt;name);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (target-&gt;chan2) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (transferer-&gt;chan2) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>ast_channel_lock(target-&gt;chan2);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>pbx_builtin_setvar_helper(target-&gt;chan2, &quot;ATTENDEDTRANSFER&quot;, transferer-&gt;chan2-&gt;name); </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>ast_channel_unlock(target-&gt;chan2);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (transferer-&gt;chan2) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>ast_channel_lock(transferer-&gt;chan2);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (target-&gt;chan1) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>pbx_builtin_setvar_helper(transferer-&gt;chan2, &quot;ATTENDEDTRANSFER&quot;, target-&gt;chan1-&gt;name);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (transferer-&gt;chan1) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>pbx_builtin_setvar_helper(transferer-&gt;chan2, &quot;ATX_FIX_CHAN&quot;, transferer-&gt;chan1-&gt;name);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ast_channel_unlock(transferer-&gt;chan2);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (transferer-&gt;chan1) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ast_channel_lock(transferer-&gt;chan1);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>pbx_builtin_setvar_helper(transferer-&gt;chan1, &quot;TRANSFERED_BY_ATXR&quot;, &quot;Yes&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>ast_channel_unlock(transferer-&gt;chan1);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div><div><br></div><div>
I think I&#39;ve done something wrong with the locking of the channels, with respect to locking order, possibly. Can you give me some pointers on what might have caused the problem?</div><div><br></div><div>Thanks!</div><div>
<br></div><div>Regards,</div><div>Ronald</div>