Perform deadlock avoidance on initial entry, too
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3343 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
779140b94c
commit
6195ae7453
20
channel.c
20
channel.c
|
@ -451,14 +451,28 @@ void ast_channel_undefer_dtmf(struct ast_channel *chan)
|
||||||
struct ast_channel *ast_channel_walk_locked(struct ast_channel *prev)
|
struct ast_channel *ast_channel_walk_locked(struct ast_channel *prev)
|
||||||
{
|
{
|
||||||
/* Returns next channel (locked) */
|
/* Returns next channel (locked) */
|
||||||
struct ast_channel *l, *ret=NULL;
|
struct ast_channel *l, *ret;
|
||||||
int retries = 0;
|
int retries = 0;
|
||||||
retry:
|
retry:
|
||||||
|
ret=NULL;
|
||||||
ast_mutex_lock(&chlock);
|
ast_mutex_lock(&chlock);
|
||||||
l = channels;
|
l = channels;
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
if (l)
|
if (l) {
|
||||||
ast_mutex_lock(&l->lock);
|
if (ast_mutex_trylock(&l->lock)) {
|
||||||
|
if (retries < 10)
|
||||||
|
ast_log(LOG_DEBUG, "Avoiding initial deadlock for '%s'\n", ret->name);
|
||||||
|
else
|
||||||
|
ast_log(LOG_WARNING, "Avoided initial deadlock for '%s', %d retries!\n", ret->name, retries);
|
||||||
|
ast_mutex_unlock(&chlock);
|
||||||
|
if (retries < 10) {
|
||||||
|
usleep(1);
|
||||||
|
retries++;
|
||||||
|
goto retry;
|
||||||
|
} else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
ast_mutex_unlock(&chlock);
|
ast_mutex_unlock(&chlock);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue