]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Account for the fact that the "other" channel can disappear while the local pvt
authorRussell Bryant <russell@russellbryant.com>
Tue, 19 Feb 2008 20:02:49 +0000 (20:02 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 19 Feb 2008 20:02:49 +0000 (20:02 +0000)
is not locked.

(fixes a problem introduced in rev 100581)
(closes issue #12012)
Reported by: stevedavies
Patch by me

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@103821 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_local.c

index 3795be9c6bab8913692438383920e2662038432d..9ea0018b2175931f13f426f82acc6e2cd293fcd2 100644 (file)
@@ -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);