[asterisk-dev] Asterisk Locking question

Ronald Cepres rbcepres at gmail.com
Thu Mar 1 01:23:14 CST 2012


Hi to all,

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:

if (ast_channel_masquerade(peerb, peerc)) {
ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", peerb->name,
peerc->name);
res = -1;
} else {
ast_log(LOG_DEBUG, "SIP transfer: Succeeded to masquerade %s into %s\n",
peerc->name, peerb->name);
if (target->chan2) {
if (transferer->chan2) {
ast_channel_lock(target->chan2);
pbx_builtin_setvar_helper(target->chan2, "ATTENDEDTRANSFER",
transferer->chan2->name);
ast_channel_unlock(target->chan2);
}
}
if (transferer->chan2) {
ast_channel_lock(transferer->chan2);
if (target->chan1) {
pbx_builtin_setvar_helper(transferer->chan2, "ATTENDEDTRANSFER",
target->chan1->name);
}
if (transferer->chan1) {
pbx_builtin_setvar_helper(transferer->chan2, "ATX_FIX_CHAN",
transferer->chan1->name);
}
ast_channel_unlock(transferer->chan2);
}
if (transferer->chan1) {
ast_channel_lock(transferer->chan1);
pbx_builtin_setvar_helper(transferer->chan1, "TRANSFERED_BY_ATXR", "Yes");
ast_channel_unlock(transferer->chan1);
}
}

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?

Thanks!

Regards,
Ronald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120301/b5c9c2dd/attachment.htm>


More information about the asterisk-dev mailing list