]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
(closes issue #10301)
authorJoshua Colp <jcolp@digium.com>
Mon, 30 Jul 2007 15:47:52 +0000 (15:47 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 30 Jul 2007 15:47:52 +0000 (15:47 +0000)
Reported by: fnordian
Patches:
      asterisk-1.4.9-channel.c.patch uploaded by fnordian (license 110)
Restore previous behavior where if we failed to lock the channel we wanted we would return to exactly the same point as if we had just reentered the function.

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

main/channel.c

index 7a5ca91dce0317e6271739c8703f4997d14698c6..2289dd84a0fcee4600c582a9ce1b817240e7efc9 100644 (file)
@@ -1032,6 +1032,7 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
        const char *msg = prev ? "deadlock" : "initial deadlock";
        int retries;
        struct ast_channel *c;
+       const struct ast_channel *_prev = prev;
 
        for (retries = 0; retries < 10; retries++) {
                int done;
@@ -1093,6 +1094,11 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
                AST_LIST_UNLOCK(&channels);
                if (done)
                        return c;
+               /* If we reach this point we basically tried to lock a channel and failed. Instead of
+                * starting from the beginning of the list we can restore our saved pointer to the previous
+                * channel and start from there.
+                */
+               prev = _prev;
                usleep(1);      /* give other threads a chance before retrying */
        }