aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_local.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-03 17:16:53 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-03 17:16:53 +0000
commit93e8762788968ec7d95651cb12954e0e52edb2d8 (patch)
tree4e197f123f36376974e37a3d7bb43244c9ad92d4 /channels/chan_local.c
parentd916d0157b1af4fed773e583a2212b3ab3970be2 (diff)
In the case of an ast_channel allocation failure, take the local_pvt out of the
pvt list before destroying it. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@105570 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r--channels/chan_local.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 93989acdb..c89d275b2 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -150,6 +150,9 @@ static int local_devicestate(void *data)
return AST_DEVICE_UNKNOWN;
}
+/*!
+ * \note Assumes the pvt is no longer in the pvts list
+ */
static struct local_pvt *local_pvt_destroy(struct local_pvt *pvt)
{
ast_mutex_destroy(&pvt->lock);
@@ -673,8 +676,12 @@ static struct ast_channel *local_request(const char *type, int format, void *dat
/* Allocate a new private structure and then Asterisk channel */
if ((p = local_alloc(data, format))) {
- if (!(chan = local_new(p, AST_STATE_DOWN)))
+ if (!(chan = local_new(p, AST_STATE_DOWN))) {
+ AST_LIST_LOCK(&locals);
+ AST_LIST_REMOVE(&locals, p, list);
+ AST_LIST_UNLOCK(&locals);
p = local_pvt_destroy(p);
+ }
}
return chan;