[asterisk-commits] mmichelson: branch 1.4 r113065 - /branches/1.4/main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 7 11:08:47 CDT 2008


Author: mmichelson
Date: Mon Apr  7 11:08:45 2008
New Revision: 113065

URL: http://svn.digium.com/view/asterisk?view=rev&rev=113065
Log:
This fix prevents a deadlock that was experienced in chan_local. There was
deadlock prevention in place in chan_local, but it would not work in a specific
case because the channel was recursively locked. By unlocking the channel prior
to calling the generator's generate callback in ast_read_generator_actions(), we
prevent the recursive locking, and therefore the deadlock.

(closes issue #12307)
Reported by: callguy
Patches:
      12307.patch uploaded by putnopvut (license 60)
Tested by: callguy


Modified:
    branches/1.4/main/channel.c

Modified: branches/1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/channel.c?view=diff&rev=113065&r1=113064&r2=113065
==============================================================================
--- branches/1.4/main/channel.c (original)
+++ branches/1.4/main/channel.c Mon Apr  7 11:08:45 2008
@@ -1896,7 +1896,17 @@
 		}
 
 		chan->generatordata = NULL;     /* reset, to let writes go through */
+		/* This unlock is here based on two assumptions that hold true at this point in the
+		 * code. 1) this function is only called from within __ast_read() and 2) all generators
+		 * call ast_write() in their generate callback.
+		 *
+		 * The reason this is added is so that when ast_write is called, the lock that occurs 
+		 * there will not recursively lock the channel. Doing this will cause intended deadlock 
+		 * avoidance not to work in deeper functions
+		 */
+		ast_channel_unlock(chan);
 		res = chan->generator->generate(chan, tmp, f->datalen, f->samples);
+		ast_channel_lock(chan);
 		chan->generatordata = tmp;
 		if (res) {
 			if (option_debug > 1)




More information about the asterisk-commits mailing list