diff options
author | Automerge script <automerge@asterisk.org> | 2013-01-03 18:20:07 +0000 |
---|---|---|
committer | Automerge script <automerge@asterisk.org> | 2013-01-03 18:20:07 +0000 |
commit | 06b4ef83179ddc1160330df5bfb19c476d8f399a (patch) | |
tree | 31d0a92a8d5ca09c41fe52e3d4643fa1b18181fa | |
parent | 01250e2585afc0feac2ed41eddc9646c875adb96 (diff) |
Merged revisions 378429 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk
................
r378429 | rmudgett | 2013-01-03 11:48:14 -0600 (Thu, 03 Jan 2013) | 10 lines
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
........
Merged revisions 378428 from http://svn.asterisk.org/svn/asterisk/branches/11
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@378436 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | channels/chan_agent.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index a9a70d01d..cab3ede4b 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -784,22 +784,21 @@ static int agent_indicate(struct ast_channel *ast, int condition, const void *da { 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; } |