mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 08:13:22 +00:00
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: https://origsvn.digium.com/svn/asterisk/branches/1.4@125740 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -186,13 +186,15 @@ static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_fra
|
|||||||
while (other && ast_channel_trylock(other)) {
|
while (other && ast_channel_trylock(other)) {
|
||||||
ast_mutex_unlock(&p->lock);
|
ast_mutex_unlock(&p->lock);
|
||||||
if (us && us_locked) {
|
if (us && us_locked) {
|
||||||
ast_channel_unlock(us);
|
do {
|
||||||
|
ast_channel_unlock(us);
|
||||||
|
usleep(1);
|
||||||
|
ast_channel_lock(us);
|
||||||
|
} while (ast_mutex_trylock(&p->lock));
|
||||||
|
} else {
|
||||||
|
usleep(1);
|
||||||
|
ast_mutex_lock(&p->lock);
|
||||||
}
|
}
|
||||||
usleep(1);
|
|
||||||
if (us && us_locked) {
|
|
||||||
ast_channel_lock(us);
|
|
||||||
}
|
|
||||||
ast_mutex_lock(&p->lock);
|
|
||||||
other = isoutbound ? p->owner : p->chan;
|
other = isoutbound ? p->owner : p->chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,7 +512,12 @@ static int local_hangup(struct ast_channel *ast)
|
|||||||
if (!p)
|
if (!p)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ast_mutex_lock(&p->lock);
|
while (ast_mutex_trylock(&p->lock)) {
|
||||||
|
ast_channel_unlock(ast);
|
||||||
|
usleep(1);
|
||||||
|
ast_channel_lock(ast);
|
||||||
|
}
|
||||||
|
|
||||||
isoutbound = IS_OUTBOUND(ast, p);
|
isoutbound = IS_OUTBOUND(ast, p);
|
||||||
if (isoutbound) {
|
if (isoutbound) {
|
||||||
const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
|
const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
|
||||||
|
Reference in New Issue
Block a user