From 33abae518ae31387859f2e79774ec8faf646a5e7 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Mon, 30 Jul 2007 15:47:52 +0000 Subject: [PATCH] (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/branches/1.4@77771 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/channel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main/channel.c b/main/channel.c index 7a5ca91dce..2289dd84a0 100644 --- a/main/channel.c +++ b/main/channel.c @@ -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 */ }