--- channel.c~ 2006-10-24 12:58:48.000000000 +0100 +++ channel.c 2006-11-16 12:44:16.000000000 +0000 @@ -799,14 +799,22 @@ if (done) return c; usleep(1); + + /* + * We are about to deadlock... Are we at the end of the list yet? If not, then SKIP this channel + * rather than giving up completely, as this might allow us to eventually resolve the deadlock. + */ + if( prev && c && retries == 10 ) { + ast_log(LOG_WARNING, "Avoided %s for '%p', %d retries!\n", + msg, c, retries); + prev = c; + retries = -1; + } } /* * c is surely not null, but we don't have the lock so cannot * access c->name */ - ast_log(LOG_WARNING, "Avoided %s for '%p', %d retries!\n", - msg, c, retries); - return NULL; }