[asterisk-commits] rmudgett: branch 11 r378428 - in /branches/11: ./ channels/chan_agent.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 3 11:46:48 CST 2013


Author: rmudgett
Date: Thu Jan  3 11:46:44 2013
New Revision: 378428

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378428
Log:
chan_agent: Fix agent_indicate() locking.

Avoid deadlock potential with local channels and simplify the locking.
........

Merged revisions 378427 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/11/   (props changed)
    branches/11/channels/chan_agent.c

Propchange: branches/11/
------------------------------------------------------------------------------
--- branch-1.8-merged (original)
+++ branch-1.8-merged Thu Jan  3 11:46:44 2013
@@ -1,1 +1,1 @@
-/branches/1.8:1-378147,378164,378356,378375
+/branches/1.8:1-378147,378164,378356,378375,378427

Modified: branches/11/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_agent.c?view=diff&rev=378428&r1=378427&r2=378428
==============================================================================
--- branches/11/channels/chan_agent.c (original)
+++ branches/11/channels/chan_agent.c Thu Jan  3 11:46:44 2013
@@ -784,22 +784,21 @@
 {
 	struct agent_pvt *p = ast_channel_tech_pvt(ast);
 	int res = -1;
+
 	ast_mutex_lock(&p->lock);
 	if (p->chan && !ast_check_hangup(p->chan)) {
-		while (ast_channel_trylock(p->chan)) {
-			if ((res = ast_channel_unlock(ast))) {
-				ast_log(LOG_ERROR, "chan_agent bug! Channel was not locked upon entry to agent_indicate: %s\n", res > 0 ? strerror(res) : "Bad ao2obj data");
-				ast_mutex_unlock(&p->lock);
-				return -1;
-			}
-			usleep(1);
-			ast_channel_lock(ast);
-		}
-  		res = ast_channel_tech(p->chan)->indicate ? ast_channel_tech(p->chan)->indicate(p->chan, condition, data, datalen) : -1;
+		ast_channel_unlock(ast);
+		ast_channel_lock(p->chan);
+		res = ast_channel_tech(p->chan)->indicate
+			? ast_channel_tech(p->chan)->indicate(p->chan, condition, data, datalen)
+			: -1;
 		ast_channel_unlock(p->chan);
-	} else
+		ast_mutex_unlock(&p->lock);
+		ast_channel_lock(ast);
+	} else {
+		ast_mutex_unlock(&p->lock);
 		res = 0;
-	ast_mutex_unlock(&p->lock);
+	}
 	return res;
 }
 




More information about the asterisk-commits mailing list