<div>Hi to all,</div><div><br></div>I'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, "Failed to masquerade %s into %s\n", peerb->name, peerc->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, "SIP transfer: Succeeded to masquerade %s into %s\n", peerc->name, peerb->name);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (target->chan2) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (transferer->chan2) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>ast_channel_lock(target->chan2);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>pbx_builtin_setvar_helper(target->chan2, "ATTENDEDTRANSFER", transferer->chan2->name); </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>ast_channel_unlock(target->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->chan2) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>ast_channel_lock(transferer->chan2);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (target->chan1) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>pbx_builtin_setvar_helper(transferer->chan2, "ATTENDEDTRANSFER", target->chan1->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->chan1) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>pbx_builtin_setvar_helper(transferer->chan2, "ATX_FIX_CHAN", transferer->chan1->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->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->chan1) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ast_channel_lock(transferer->chan1);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>pbx_builtin_setvar_helper(transferer->chan1, "TRANSFERED_BY_ATXR", "Yes");</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>ast_channel_unlock(transferer->chan1);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div><div><br></div><div>
I think I'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>