aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-23 17:41:51 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-23 17:41:51 +0000
commitcb8eee8b42a73eaa5c7c746b0deb317b891de9af (patch)
treebd1b4b1c89557fc6a0f8566532b95fc5ca12d287 /channel.c
parent393905e04482c2b64e7e4d4a271d6e9a594fe527 (diff)
Be sure to hold lock during answer
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3286 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/channel.c b/channel.c
index 89ebcbb4b..dd2b81429 100755
--- a/channel.c
+++ b/channel.c
@@ -750,16 +750,17 @@ void ast_channel_unregister(char *type)
int ast_answer(struct ast_channel *chan)
{
int res = 0;
+ ast_mutex_lock(&chan->lock);
/* Stop if we're a zombie or need a soft hangup */
- if (chan->zombie || ast_check_hangup(chan))
+ if (chan->zombie || ast_check_hangup(chan)) {
+ ast_mutex_unlock(&chan->lock);
return -1;
+ }
switch(chan->_state) {
case AST_STATE_RINGING:
case AST_STATE_RING:
- ast_mutex_lock(&chan->lock);
if (chan->pvt->answer)
res = chan->pvt->answer(chan);
- ast_mutex_unlock(&chan->lock);
ast_setstate(chan, AST_STATE_UP);
if (chan->cdr)
ast_cdr_answer(chan->cdr);
@@ -770,6 +771,7 @@ int ast_answer(struct ast_channel *chan)
ast_cdr_answer(chan->cdr);
break;
}
+ ast_mutex_unlock(&chan->lock);
return 0;
}