[svn-commits] mmichelson: trunk r88827 - in /trunk: ./ main/channel.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Nov 5 17:31:00 CST 2007


Author: mmichelson
Date: Mon Nov  5 17:31:00 2007
New Revision: 88827

URL: http://svn.digium.com/view/asterisk?view=rev&rev=88827
Log:
Merged revisions 88826 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r88826 | mmichelson | 2007-11-05 17:29:29 -0600 (Mon, 05 Nov 2007) | 6 lines

Reworked deadlock avoidance in __ast_read. Restored audio to 
callback agents.

(closes issue #11071, reported by callguy, patched by me, tested by callguy and Ted Brown)


........

Modified:
    trunk/   (props changed)
    trunk/main/channel.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=88827&r1=88826&r2=88827
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Mon Nov  5 17:31:00 2007
@@ -2121,14 +2121,20 @@
 static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
 {
 	struct ast_frame *f = NULL;	/* the return value */
-	struct ast_channel *base = NULL;
 	int blah;
 	int prestate;
+	int count = 0;
 
 	/* this function is very long so make sure there is only one return
-	 * point at the end (there is only one exception to this).
+	 * point at the end (there are only two exceptions to this).
 	 */
-	ast_channel_lock(chan);
+	while(ast_channel_trylock(chan)) {
+		if(count++ > 10) 
+			/*cannot goto done since the channel is not locked*/
+			return &ast_null_frame;
+		usleep(1);
+	}
+
 	if (chan->masq) {
 		if (ast_do_masquerade(chan))
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
@@ -2144,23 +2150,6 @@
 		goto done;
 	}
 	prestate = chan->_state;
-
-	/* Check if there's an underlying channel */
-	if (chan->tech->get_base_channel && (base = chan->tech->get_base_channel(chan)) != chan) {
-		int count = 0;
-		while (!base || ast_mutex_trylock(&base->lock)) {
-			if (count++ > 10) {
-				f = &ast_null_frame;
-				goto done;
-			}
-			ast_mutex_unlock(&chan->lock);
-			usleep(1);
-			ast_mutex_lock(&chan->lock);
-			base = chan->tech->get_base_channel(chan);
-		}
-		ast_mutex_unlock(&chan->lock);
-		chan = base;
-	}
 
 	if (!ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF | AST_FLAG_IN_DTMF) && 
 	    !ast_strlen_zero(chan->dtmfq) && 




More information about the svn-commits mailing list