move the calls to ast_jb_configure() to before the PBX thread is started on the

channel to remove the theoretical race condition that the channel could get
bridged before the channel's jitterbuffer gets configured.  This was pointed
out by PCadach on IRC.  Thanks!


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@39964 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2006-08-16 03:43:47 +00:00
parent b6a99250ed
commit 9f9a5f1984
7 changed files with 13 additions and 24 deletions

View File

@ -829,6 +829,7 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
usecnt++;
ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
ast_jb_configure(tmp, &global_jbconf);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@ -836,8 +837,6 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
tmp = NULL;
}
}
if (tmp)
ast_jb_configure(tmp, &global_jbconf);
}
return tmp;
}

View File

@ -826,6 +826,8 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
ch->cid.cid_dnid = strdup(pvt->exten);
}
ast_setstate(ch, state);
if (pvt->rtp)
ast_jb_configure(ch, &global_jbconf);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(ch)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ch->name);
@ -833,10 +835,6 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
ch = NULL;
}
}
/* Configure the new channel jb */
if (ch && pvt && pvt->rtp)
ast_jb_configure(ch, &global_jbconf);
} else {
ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
}

View File

@ -813,6 +813,8 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
tmp->cid.cid_dnid = ast_strdup(i->exten);
tmp->priority = 1;
ast_setstate(tmp, state);
if (i->rtp)
ast_jb_configure(tmp, &global_jbconf);
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;
@ -820,10 +822,6 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
tmp = NULL;
}
/* Configure the new channel jb */
if (tmp && i && i->rtp)
ast_jb_configure(tmp, &global_jbconf);
return tmp;
}

View File

@ -1425,6 +1425,8 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
if (!i->adsi)
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
tmp->priority = 1;
if (sub->rtp)
ast_jb_configure(tmp, &global_jbconf);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@ -1437,10 +1439,6 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_new(%s) created in state: %s\n",
tmp->name, ast_state2str(state));
}
/* Configure the new channel jb */
if (tmp && sub && sub->rtp)
ast_jb_configure(tmp, &global_jbconf);
} else {
ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
}

View File

@ -1021,6 +1021,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o,
usecnt++;
ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
ast_jb_configure(c, &global_jbconf);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(c)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
@ -1030,8 +1031,6 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o,
/* XXX what about usecnt ? */
}
}
if (c)
ast_jb_configure(c, &global_jbconf);
return c;
}

View File

@ -3703,6 +3703,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
if (!ast_strlen_zero(i->callid))
pbx_builtin_setvar_helper(tmp, "SIPCALLID", i->callid);
ast_setstate(tmp, state);
if (i->rtp)
ast_jb_configure(tmp, &global_jbconf);
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;
@ -3716,10 +3718,6 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
if (recordhistory)
append_history(i, "NewChan", "Channel %s - from %s", tmp->name, i->callid);
/* Configure the new channel jb */
if (tmp && i && i->rtp)
ast_jb_configure(tmp, &global_jbconf);
return tmp;
}

View File

@ -2592,6 +2592,9 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state)
tmp->priority = 1;
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
if (sub->rtp)
ast_jb_configure(tmp, &global_jbconf);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@ -2599,10 +2602,6 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state)
tmp = NULL;
}
}
/* Configure the new channel jb */
if (tmp && sub->rtp)
ast_jb_configure(tmp, &global_jbconf);
}
return tmp;
}