Merged revisions 77771 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Mon, 30 Jul 2007 15:49:30 +0000 (15:49 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 30 Jul 2007 15:49:30 +0000 (15:49 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r77771 | file | 2007-07-30 12:47:52 -0300 (Mon, 30 Jul 2007) | 6 lines

(closes issue #10301)
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/trunk@77772 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index c1b3b88..bc60413 100644 (file)
@@ -929,6 +929,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;
@@ -988,6 +989,11 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
                AST_RWLIST_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 */
        }