[asterisk-commits] mnicholson: branch 1.4 r311203 -	/branches/1.4/channels/chan_agent.c
    SVN commits to the Asterisk project 
    asterisk-commits at lists.digium.com
       
    Thu Mar 17 14:14:41 CDT 2011
    
    
  
Author: mnicholson
Date: Thu Mar 17 14:14:37 2011
New Revision: 311203
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311203
Log:
Don't hold the pvt lock while streaming a file.
ABE-2756
Modified:
    branches/1.4/channels/chan_agent.c
Modified: branches/1.4/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/channels/chan_agent.c?view=diff&rev=311203&r1=311202&r2=311203
==============================================================================
--- branches/1.4/channels/chan_agent.c (original)
+++ branches/1.4/channels/chan_agent.c Thu Mar 17 14:14:37 2011
@@ -751,6 +751,7 @@
 	struct agent_pvt *p = ast->tech_pvt;
 	int res = -1;
 	int newstate=0;
+	struct ast_channel *chan;
 	ast_mutex_lock(&p->lock);
 	p->acknowledged = 0;
 	if (!p->chan) {
@@ -783,14 +784,25 @@
 		ast_verbose(VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
-	res = ast_streamfile(p->chan, beep, p->chan->language);
+
+	chan = p->chan;
+	ast_mutex_unlock(&p->lock);
+
+	res = ast_streamfile(chan, beep, chan->language);
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
 	if (!res) {
-		res = ast_waitstream(p->chan, "");
+		res = ast_waitstream(chan, "");
 		if (option_debug > 2)
 			ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
 	}
+
+	ast_mutex_lock(&p->lock);
+	if (p->chan != chan) {
+		/* chan went away while we were streaming */
+		res = -1;
+	}
+
 	if (!res) {
 		res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
 		if (option_debug > 2)
    
    
More information about the asterisk-commits
mailing list