aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-09 02:37:18 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-09 02:37:18 +0000
commit9af220fc48bfd979b6e75bcb3d722d9f00bb829f (patch)
tree2c826360ea150bcb8c67442101720143c481d0d2
parentaf181586db60762d9324e057ab5af0f0bef9832c (diff)
Bug 9505 - If the return value for local_queue_frame is set, then p->lock is no longer valid.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@60846 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_local.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index df442a0ad..9dceded67 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -179,7 +179,8 @@ static int local_answer(struct ast_channel *ast)
res = local_queue_frame(p, isoutbound, &answer, ast);
} else
ast_log(LOG_WARNING, "Huh? Local is being asked to answer?\n");
- ast_mutex_unlock(&p->lock);
+ if (!res)
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -262,7 +263,8 @@ static int local_write(struct ast_channel *ast, struct ast_frame *f)
ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name);
res = 0;
}
- ast_mutex_unlock(&p->lock);
+ if (!res)
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -302,8 +304,8 @@ static int local_indicate(struct ast_channel *ast, int condition)
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
f.subclass = condition;
- res = local_queue_frame(p, isoutbound, &f, ast);
- ast_mutex_unlock(&p->lock);
+ if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -320,8 +322,8 @@ static int local_digit(struct ast_channel *ast, char digit)
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
f.subclass = digit;
- res = local_queue_frame(p, isoutbound, &f, ast);
- ast_mutex_unlock(&p->lock);
+ if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -340,8 +342,8 @@ static int local_sendhtml(struct ast_channel *ast, int subclass, const char *dat
f.subclass = subclass;
f.data = (char *)data;
f.datalen = datalen;
- res = local_queue_frame(p, isoutbound, &f, ast);
- ast_mutex_unlock(&p->lock);
+ if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+ ast_mutex_unlock(&p->lock);
return res;
}
@@ -430,7 +432,7 @@ static int local_hangup(struct ast_channel *ast)
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
struct local_pvt *cur, *prev=NULL;
struct ast_channel *ochan = NULL;
- int glaredetect;
+ int glaredetect, res = 0;
if (!p)
return -1;
@@ -485,8 +487,9 @@ static int local_hangup(struct ast_channel *ast)
/* Need to actually hangup since there is no PBX */
ochan = p->chan;
else
- local_queue_frame(p, isoutbound, &f, NULL);
- ast_mutex_unlock(&p->lock);
+ res = local_queue_frame(p, isoutbound, &f, NULL);
+ if (!res)
+ ast_mutex_unlock(&p->lock);
if (ochan)
ast_hangup(ochan);
return 0;