Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 306368) +++ channels/chan_sip.c (working copy) @@ -6533,7 +6533,7 @@ sip_pvt_lock(i); ast_channel_cc_params_init(tmp, i->cc_params); tmp->caller.id.tag = ast_strdup(i->cid_tag); - ast_channel_unlock(tmp); + ast_channel_unlock(tmp); /* this lock is needed below, so deadlock avoidance is required */ tmp->tech = ( ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INFO || ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_SHORTINFO) ? &sip_tech_info : &sip_tech; @@ -6674,6 +6674,13 @@ tmp->dialed.number.str = ast_strdup(i->exten); } + /* pbx_builtin_setvar_helper locks the channel */ + while (ast_channel_trylock(tmp)) { + sip_pvt_unlock(i); + sched_yield(); + sip_pvt_lock(i); + } + tmp->priority = 1; if (!ast_strlen_zero(i->uri)) pbx_builtin_setvar_helper(tmp, "SIPURI", i->uri); @@ -6706,6 +6713,7 @@ "Channel: %s\r\nUniqueid: %s\r\nChanneltype: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\n", tmp->name, tmp->uniqueid, "SIP", i->callid, i->fullcontact); + ast_channel_unlock(tmp); return tmp; }