diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_local.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c index d5441d047..e705ee582 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -543,12 +543,12 @@ static int local_hangup(struct ast_channel *ast) /* Deadlock avoidance */ while (p->owner && ast_channel_trylock(p->owner)) { ast_mutex_unlock(&p->lock); - if (ast) { - ast_channel_unlock(ast); + if (p->chan) { + ast_channel_unlock(p->chan); } usleep(1); - if (ast) { - ast_channel_lock(ast); + if (p->chan) { + ast_channel_lock(p->chan); } ast_mutex_lock(&p->lock); } @@ -563,8 +563,17 @@ static int local_hangup(struct ast_channel *ast) } else { ast_module_user_remove(p->u_owner); while (p->chan && ast_channel_trylock(p->chan)) { - DEADLOCK_AVOIDANCE(&p->lock); + ast_mutex_unlock(&p->lock); + if (p->owner) { + ast_channel_unlock(p->owner); + } + usleep(1); + if (p->owner) { + ast_channel_lock(p->owner); + } + ast_mutex_lock(&p->lock); } + p->owner = NULL; if (p->chan) { ast_queue_hangup(p->chan); |