aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_oss.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-22 17:05:17 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-22 17:05:17 +0000
commit75865d5802e68f217cb6d5b27e205948a935883e (patch)
tree09e0da9c9e65e62322d7b473d2f44a59feef1bbb /channels/chan_oss.c
parentf3f7a9e1aaee38f18bc703bef74d441b3069eb41 (diff)
- 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: http://svn.digium.com/svn/asterisk/trunk@35553 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_oss.c')
-rw-r--r--channels/chan_oss.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 98ca519de..36a418bd0 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1000,21 +1000,24 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o,
o->owner = c;
ast_setstate(c, state);
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ if (ast_jb_configure(c, &global_jbconf)) {
+ ast_hangup(c);
+ o->owner = NULL;
+ return NULL;
+ }
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(c)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
ast_hangup(c);
- o->owner = c = NULL;
- /* XXX what about the channel itself ? */
- /* XXX what about usecnt ? */
+ o->owner = NULL;
+ return NULL;
}
}
- if (c)
- ast_jb_configure(c, &global_jbconf);
+
+ ast_mutex_lock(&usecnt_lock);
+ usecnt++;
+ ast_mutex_unlock(&usecnt_lock);
+ ast_update_use_count();
return c;
}