aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_agent.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-10 21:15:57 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-10 21:15:57 +0000
commit9e7cf18b4d919f8aa63305c3772bbfc49aff4a55 (patch)
tree483f28c75569dc3ec3da72a51775005c0c9cf22e /channels/chan_agent.c
parentafe56064c7528a3a833705218d682cf00c212316 (diff)
Merged revisions 155863 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r155863 | mmichelson | 2008-11-10 15:14:44 -0600 (Mon, 10 Nov 2008) | 22 lines Merged revisions 155861 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r155861 | mmichelson | 2008-11-10 15:07:39 -0600 (Mon, 10 Nov 2008) | 14 lines Channel drivers assume that when their indicate callback is invoked, that the channel on which the callback was called is locked. This patch corrects an instance in chan_agent where a channel's indicate callback is called directly without first locking the channel. This was leading to some observed locking issues in chan_local, but considering that all channel drivers operate under the same expectations, the generic fix in chan_agent is the right way to go. AST-126 ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@155864 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_agent.c')
-rw-r--r--channels/chan_agent.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 13d98cb83..5cf24572a 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -655,9 +655,15 @@ static int agent_indicate(struct ast_channel *ast, int condition, const void *da
struct agent_pvt *p = ast->tech_pvt;
int res = -1;
ast_mutex_lock(&p->lock);
- if (p->chan && !ast_check_hangup(p->chan))
- res = p->chan->tech->indicate ? p->chan->tech->indicate(p->chan, condition, data, datalen) : -1;
- else
+ if (p->chan && !ast_check_hangup(p->chan)) {
+ while (ast_channel_trylock(p->chan)) {
+ ast_channel_unlock(ast);
+ usleep(1);
+ ast_channel_lock(ast);
+ }
+ res = p->chan->tech->indicate ? p->chan->tech->indicate(p->chan, condition, data, datalen) : -1;
+ ast_channel_unlock(p->chan);
+ } else
res = 0;
ast_mutex_unlock(&p->lock);
return res;