- move the increase of the use count to be after the possible failures

- if the pbx fails to start, set the owner channel of the pvt strucutre
  to be NULL
- return immediately if the pbx fails to start so the loop to set all of
  the variables from the "setvar" options aren't set as a bunch of global
  variables instead


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@35554 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2006-06-22 17:10:16 +00:00
parent 46018d5032
commit 5941d4d819

View File

@@ -3307,20 +3307,20 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
i->owner = tmp;
i->capability = capability;
ast_setstate(tmp, state);
ast_mutex_lock(&usecnt_lock);
usecnt++;
ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
ast_hangup(tmp);
tmp = NULL;
i->owner = NULL;
return NULL;
}
}
for (v = i->vars ; v ; v = v->next)
pbx_builtin_setvar_helper(tmp,v->name,v->value);
ast_mutex_lock(&usecnt_lock);
usecnt++;
ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
}
return tmp;
}