Merged revisions 38903-38904 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r38903 | russell | 2006-08-05 01:07:39 -0400 (Sat, 05 Aug 2006) | 2 lines

suppress a compiler warning about the usage of a potentially uninitialized variable

........
r38904 | russell | 2006-08-05 01:08:50 -0400 (Sat, 05 Aug 2006) | 10 lines

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: https://origsvn.digium.com/svn/asterisk/trunk@38905 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 19 years ago
parent f41f7f8c93
commit 663adb2b0e

@ -3625,7 +3625,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
}
for (/* ever */;;) {
struct timeval now;
struct timeval now = { 0, };
int to;
to = -1;

@ -796,18 +796,19 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
if (pvt->amaflags) {
ch->amaflags = pvt->amaflags;
}
/*
* If cid_num and cd.call_source_e164 are both null, then
* ast_set_callerid will do the right thing and leave the
* cid_num and cid_ani for the channel alone.
*/
ast_set_callerid(ch,
!ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164,
!ast_strlen_zero(pvt->cid_name) ? pvt->cid_name : pvt->cd.call_source_name,
!ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164);
if (!ast_strlen_zero(pvt->rdnis)) {
ch->cid.cid_rdnis = strdup(pvt->rdnis);
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
if (!ast_strlen_zero(pvt->cid_num)) {
ch->cid.cid_num = ast_strdup(pvt->cid_num);
ch->cid.cid_ani = ast_strdup(pvt->cid_num);
} else {
ch->cid.cid_num = ast_strdup(pvt->cd.call_source_e164);
ch->cid.cid_ani = ast_strdup(pvt->cd.call_source_e164);
}
ch->cid.cid_name = ast_strdup(pvt->cid_name);
ch->cid.cid_rdnis = ast_strdup(pvt->rdnis);
if (!ast_strlen_zero(pvt->exten) && strcmp(pvt->exten, "s")) {
ch->cid.cid_dnid = strdup(pvt->exten);
}

@ -3259,16 +3259,21 @@ 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, S_OR(i->ani, i->cid_num));
if (!ast_strlen_zero(i->language))
ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->dnid))
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
tmp->cid.cid_num = ast_strdup(i->cid_num);
tmp->cid.cid_name = ast_strdup(i->cid_name);
if (!ast_strlen_zero(i->ani))
tmp->cid.cid_ani = ast_strdup(i->ani);
else
tmp->cid.cid_ani = ast_strdup(i->cid_num);
tmp->cid.cid_dnid = ast_strdup(i->dnid);
if (!ast_strlen_zero(i->rdnis))
tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
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_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->accountcode))
ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)

@ -1415,7 +1415,13 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
ast_string_field_set(tmp, call_forward, i->call_forward);
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
tmp->cid.cid_num = ast_strdup(i->cid_num);
tmp->cid.cid_ani = ast_strdup(i->cid_num);
tmp->cid.cid_name = ast_strdup(i->cid_name);
if (!i->adsi)
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
tmp->priority = 1;

@ -3099,9 +3099,11 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char
char *cid_name, *cid_num;
ast_callerid_parse(callerid, &cid_name, &cid_num);
ast_set_callerid(tmp, cid_num,cid_name,cid_num);
} else {
ast_set_callerid(tmp, NULL,NULL,NULL);
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
tmp->cid.cid_num = ast_strdup(cid_num);
tmp->cid.cid_ani = ast_strdup(cid_num);
tmp->cid.cid_name = ast_strdup(cid_name);
}
{

@ -864,7 +864,13 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
if (!ast_strlen_zero(i->language))
ast_string_field_set(tmp, language, i->language);
ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
tmp->cid.cid_num = ast_strdup(i->cid_num);
tmp->cid.cid_ani = ast_strdup(i->cid_num);
tmp->cid.cid_name = ast_strdup(i->cid_name);
i->owner = tmp;
ast_mutex_lock(&usecnt_lock);
usecnt++;

@ -3682,11 +3682,17 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
ast_update_use_count();
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
if (!ast_strlen_zero(i->rdnis))
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
tmp->cid.cid_num = ast_strdup(i->cid_num);
tmp->cid.cid_ani = ast_strdup(i->cid_num);
tmp->cid.cid_name = ast_strdup(i->cid_name);
tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
tmp->cid.cid_dnid = ast_strdup(i->exten);
tmp->priority = 1;
if (!ast_strlen_zero(i->uri))
pbx_builtin_setvar_helper(tmp, "SIPURI", i->uri);

@ -2582,7 +2582,13 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state)
ast_string_field_set(tmp, call_forward, l->call_forward);
ast_copy_string(tmp->context, l->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, l->exten, sizeof(tmp->exten));
ast_set_callerid(tmp, l->cid_num, l->cid_name, l->cid_num);
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
tmp->cid.cid_num = ast_strdup(l->cid_num);
tmp->cid.cid_ani = ast_strdup(l->cid_num);
tmp->cid.cid_name = ast_strdup(l->cid_name);
tmp->priority = 1;
tmp->adsicpe = AST_ADSI_UNAVAILABLE;

@ -5217,9 +5217,18 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
tmp->cid.cid_dnid = ast_strdup(i->dnid);
#ifdef PRI_ANI
ast_set_callerid(tmp, i->cid_num, i->cid_name, S_OR(i->cid_ani, i->cid_num));
/* Don't use ast_set_callerid() here because it will
* generate a NewCallerID event before the NewChannel event */
tmp->cid.cid_num = ast_strdup(i->cid_num);
tmp->cid.cid_name = ast_strdup(i->cid_name);
if (!ast_strlen_zero(i->cid_ani))
tmp->cid.cid_ani = ast_strdup(i->cid_num);
else
tmp->cid.cid_ani = ast_strdup(i->cid_num);
#else
ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
tmp->cid.cid_num = ast_strdup(i->cid_num);
tmp->cid.cid_ani = ast_strdup(i->cid_num);
tmp->cid.cid_name = ast_strdup(i->cid_name);
#endif
tmp->cid.cid_pres = i->callingpres;
tmp->cid.cid_ton = i->cid_ton;

Loading…
Cancel
Save