From 9f9a5f19845e38b8829fdff94837b9b760692404 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 16 Aug 2006 03:43:47 +0000 Subject: [PATCH] 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 --- channels/chan_alsa.c | 3 +-- channels/chan_h323.c | 6 ++---- channels/chan_jingle.c | 6 ++---- channels/chan_mgcp.c | 6 ++---- channels/chan_oss.c | 3 +-- channels/chan_sip.c | 6 ++---- channels/chan_skinny.c | 7 +++---- 7 files changed, 13 insertions(+), 24 deletions(-) diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index aeadc340c0..2702621f7b 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -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; } diff --git a/channels/chan_h323.c b/channels/chan_h323.c index cd9f3ecfff..1ce5b345e3 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -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"); } diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c index 9bf77cc273..bfa79e4547 100644 --- a/channels/chan_jingle.c +++ b/channels/chan_jingle.c @@ -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; } diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 7b56b8c985..07da3a75d3 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -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"); } diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 48af9768e9..99ad260461 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -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; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 026df911c8..9e5493d078 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -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; } diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 00b54f0155..498b87cfd5 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -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; }