diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-05 05:08:50 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-05 05:08:50 +0000 |
commit | f05aa97fe5ee633cffc5641a9395f0c06ca27de5 (patch) | |
tree | ae71fb6b76d48d499d0f8c8db72cfb68cc837b7f /channels/chan_iax2.c | |
parent | 85d8708df8c31feb766348a0772cc0c652765aa5 (diff) |
Fix an issue that would cause a NewCallerID manager event to be generated
before the channel's NewChannel event. This was due to a somewhat recent
change that included using ast_set_callerid() where it wasn't before. This
function should not be used in the channel driver "new" functions.
(issue #7654, fixed by me)
Also, fix a couple minor bugs in usecount handling. chan_iax2 could have
increased the usecount but then returned an error. The place where chan_sip
increased the usecount did not call ast_update_usecount()
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@38904 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index d1e33f408..61fc2ca36 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -3442,15 +3442,22 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability) tmp->writeformat = ast_best_codec(capability); tmp->tech_pvt = CALLNO_TO_PTR(i->callno); - ast_set_callerid(tmp, i->cid_num, i->cid_name, - i->ani ? i->ani : i->cid_num); + if (!ast_strlen_zero(i->cid_num)) + tmp->cid.cid_num = strdup(i->cid_num); + if (!ast_strlen_zero(i->cid_name)) + tmp->cid.cid_name = strdup(i->cid_name); + if (!ast_strlen_zero(i->ani)) + tmp->cid.cid_ani = strdup(i->ani); + else if (!ast_strlen_zero(i->cid_num)) + tmp->cid.cid_ani = strdup(i->cid_num); + tmp->cid.cid_pres = i->calling_pres; + tmp->cid.cid_ton = i->calling_ton; + tmp->cid.cid_tns = i->calling_tns; + if (!ast_strlen_zero(i->language)) ast_copy_string(tmp->language, i->language, sizeof(tmp->language)); if (!ast_strlen_zero(i->dnid)) tmp->cid.cid_dnid = strdup(i->dnid); - tmp->cid.cid_pres = i->calling_pres; - tmp->cid.cid_ton = i->calling_ton; - tmp->cid.cid_tns = i->calling_tns; if (!ast_strlen_zero(i->accountcode)) ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode)); if (i->amaflags) @@ -3461,10 +3468,6 @@ 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); @@ -3475,6 +3478,10 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability) 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; } |