diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-02-19 20:02:49 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-02-19 20:02:49 +0000 |
commit | 5d136d4cd0092c4d97bba395674a3deb19e640dd (patch) | |
tree | 09162422f4d9322a801cc6c1ea42fbdcd8a74579 /channels/chan_local.c | |
parent | 0ba25574740d9d6adff2851c395c5bda47abb0a0 (diff) |
Account for the fact that the "other" channel can disappear while the local pvt
is not locked.
(fixes a problem introduced in rev 100581)
(closes issue #12012)
Reported by: stevedavies
Patch by me
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@103821 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r-- | channels/chan_local.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c index 3795be9c6..9ea0018b2 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -172,24 +172,22 @@ static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_fra return 0; } - ast_mutex_unlock(&p->lock); - /* Ensure that we have both channels locked */ - if (us) { - while (ast_channel_trylock(other)) { + while (other && ast_channel_trylock(other)) { + ast_mutex_unlock(&p->lock); + if (us) ast_channel_unlock(us); - usleep(1); + usleep(1); + if (us) ast_channel_lock(us); - } - } else { - ast_channel_lock(other); + ast_mutex_lock(&p->lock); + other = isoutbound ? p->owner : p->chan; } - ast_queue_frame(other, f); - - ast_channel_unlock(other); - - ast_mutex_lock(&p->lock); + if (other) { + ast_queue_frame(other, f); + ast_channel_unlock(other); + } ast_clear_flag(p, LOCAL_GLARE_DETECT); |