]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Resolves a deadlock that occurs during sip_new
authorJonathan Rose <jrose@digium.com>
Thu, 5 May 2011 19:09:13 +0000 (19:09 +0000)
committerJonathan Rose <jrose@digium.com>
Thu, 5 May 2011 19:09:13 +0000 (19:09 +0000)
This is based on an uncommitted patch by jpeeler for the issue.  Instead of
relocking and then unlocking the channel though, we keep the lock on the channel
until we are finished doing what we need to the channel.

(closes issue #18441)
Reported by: Alric

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@317283 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 8b9ed8c2019d3f75ee21f242ca39e95ccd0a6a67..6e1f6d54180a180ac69646ad9376b42b20a3a70f 100644 (file)
@@ -6681,7 +6681,6 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        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);
 
        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;
 
@@ -6838,6 +6837,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
                pbx_builtin_setvar_helper(tmp, v->name, ast_get_encoded_str(v->value, valuebuf, sizeof(valuebuf)));
        }
 
+       ast_channel_unlock(tmp); /* ast_hangup requires the channel to be unlocked */
+
        if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) {
                ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
                tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;