diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-27 12:28:38 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-27 12:28:38 +0000 |
commit | 31c979ade9b24dad9580dd485fe75e6a399b4140 (patch) | |
tree | c4026e11ca677e5224dc269ae0f24ceb0fbe1861 /channels/chan_local.c | |
parent | 6a998ab4e96f87a30f13c6a4f32a4926712b2d72 (diff) |
Merged revisions 125740 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r125740 | tilghman | 2008-06-27 07:19:39 -0500 (Fri, 27 Jun 2008) | 7 lines
Add proper deadlock avoidance.
(closes issue #12914)
Reported by: ozan
Patches:
20080625__bug12914.diff.txt uploaded by Corydon76 (license 14)
Tested by: ozan
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@125741 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r-- | channels/chan_local.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c index 0a1a1695d..499df7269 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -219,13 +219,15 @@ static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_fra /* Ensure that we have both channels locked */ while (other && ast_channel_trylock(other)) { - DLA_UNLOCK(&p->lock); + ast_mutex_unlock(&p->lock); if (us && us_locked) { - CHANNEL_DEADLOCK_AVOIDANCE(us); + do { + CHANNEL_DEADLOCK_AVOIDANCE(us); + } while (ast_mutex_trylock(&p->lock)); } else { usleep(1); + ast_mutex_lock(&p->lock); } - DLA_LOCK(&p->lock); other = isoutbound ? p->owner : p->chan; } @@ -542,7 +544,12 @@ static int local_hangup(struct ast_channel *ast) if (!p) return -1; - ast_mutex_lock(&p->lock); + while (ast_mutex_trylock(&p->lock)) { + ast_channel_unlock(ast); + usleep(1); + ast_channel_lock(ast); + } + if (p->chan && ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE); isoutbound = IS_OUTBOUND(ast, p); |