Index: main/pbx.c =================================================================== --- main/pbx.c (revision 313524) +++ main/pbx.c (working copy) @@ -4267,7 +4267,11 @@ /* Device state changed since last check - notify the watchers */ ao2_lock(hints); - ao2_lock(hint); + while (ao2_trylock(hint)) { + ao2_unlock(hints); + usleep(1); + ao2_lock(hints); + } if (hint->exten == NULL) { /* the extension has been destroyed */ Index: main/channel.c =================================================================== --- main/channel.c (revision 313524) +++ main/channel.c (working copy) @@ -6240,8 +6240,12 @@ */ ao2_lock(channels); - /* lock the original channel to determine if the masquerade is require or not */ - ast_channel_lock(original); + /* lock the original channel with deadlock avoidance to determine if the masquerade is require or not */ + while (ast_channel_trylock(original)) { + ao2_unlock(channels); + usleep(1); + ao2_lock(channels); + } /* This checks to see if the masquerade has already happened or not. There is a * race condition that exists for this function. Since all pvt and channel locks