summaryrefslogtreecommitdiff
path: root/channels/chan_local.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r--channels/chan_local.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 3f4cfb5fb..e42368e32 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -501,8 +501,16 @@ static int local_hangup(struct ast_channel *ast)
isoutbound = IS_OUTBOUND(ast, p);
if (isoutbound) {
const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
- if ((status) && (p->owner))
+ if ((status) && (p->owner)) {
+ /* Deadlock avoidance */
+ while (ast_channel_trylock(p->owner)) {
+ ast_mutex_unlock(&p->lock);
+ usleep(1);
+ ast_mutex_lock(&p->lock);
+ }
pbx_builtin_setvar_helper(p->owner, "CHANLOCALSTATUS", status);
+ ast_channel_unlock(p->owner);
+ }
p->chan = NULL;
ast_clear_flag(p, LOCAL_LAUNCHED_PBX);
ast_module_user_remove(p->u_chan);