[Asterisk-cvs] asterisk channel.c,1.121,1.122

markster at lists.digium.com markster at lists.digium.com
Wed Jun 23 13:55:57 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv30004

Modified Files:
	channel.c 
Log Message:
Be sure to hold lock during answer


Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- channel.c	22 Jun 2004 20:11:15 -0000	1.121
+++ channel.c	23 Jun 2004 17:41:51 -0000	1.122
@@ -750,16 +750,17 @@
 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 @@
 			ast_cdr_answer(chan->cdr);
 		break;
 	}
+	ast_mutex_unlock(&chan->lock);
 	return 0;
 }
 




More information about the svn-commits mailing list