From 46018d50321331c5d094a002f5f40540c8e7f052 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 22 Jun 2006 17:05:17 +0000 Subject: - dynamically allocate the ast_jb structure that is on the channel structure so that channels not using a jitterbuffer don't waste as much memory - ensure that the channel drivers that use jitterbuffers can handle a failure from configuring a jitterbuffer on a new channel because of a memory allocation error - On passing through these channel drivers, configure the jitterbuffer before starting the PBX thread instead of afterwards. If the pbx fails to start for whatever reason, this would have caused a crash. - Also on passing, move the increase of the usecount to after all of the possible failure conditions in the function - fix a place where ast_update_use_count() was not called - ensure that the owner channel pointer of the channel pvt strcutures is set to NULL in failure conditions git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@35553 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_skinny.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'channels/chan_skinny.c') diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 899bd13df..da7d118f6 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -2516,10 +2516,6 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state) if (l->amaflags) tmp->amaflags = l->amaflags; - ast_mutex_lock(&usecnt_lock); - usecnt++; - ast_mutex_unlock(&usecnt_lock); - ast_update_use_count(); tmp->callgroup = l->callgroup; tmp->pickupgroup = l->pickupgroup; ast_string_field_set(tmp, call_forward, l->call_forward); @@ -2530,18 +2526,29 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state) tmp->priority = 1; tmp->adsicpe = AST_ADSI_UNAVAILABLE; + /* Configure the new channel jb */ + if (sub->rtp) { + if (ast_jb_configure(tmp, &global_jbconf)) { + ast_hangup(tmp); + sub->owner = NULL; + return NULL; + } + } 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; + sub->owner = NULL; + return NULL; } } - - /* Configure the new channel jb */ - if (tmp && sub->rtp) - ast_jb_configure(tmp, &global_jbconf); } + + ast_mutex_lock(&usecnt_lock); + usecnt++; + ast_mutex_unlock(&usecnt_lock); + ast_update_use_count(); + return tmp; } -- cgit v1.2.3