aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channels/chan_local.c19
-rw-r--r--main/channel.c7
2 files changed, 16 insertions, 10 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 7ed607d2c..2cd02c961 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -580,12 +580,12 @@ static int local_hangup(struct ast_channel *ast)
/* Deadlock avoidance */
while (p->owner && ast_channel_trylock(p->owner)) {
ast_mutex_unlock(&p->lock);
- if (ast) {
- ast_channel_unlock(ast);
+ if (p->chan) {
+ ast_channel_unlock(p->chan);
}
usleep(1);
- if (ast) {
- ast_channel_lock(ast);
+ if (p->chan) {
+ ast_channel_lock(p->chan);
}
ast_mutex_lock(&p->lock);
}
@@ -600,8 +600,17 @@ static int local_hangup(struct ast_channel *ast)
} else {
ast_module_user_remove(p->u_owner);
while (p->chan && ast_channel_trylock(p->chan)) {
- DEADLOCK_AVOIDANCE(&p->lock);
+ ast_mutex_unlock(&p->lock);
+ if (p->owner) {
+ ast_channel_unlock(p->owner);
+ }
+ usleep(1);
+ if (p->owner) {
+ ast_channel_lock(p->owner);
+ }
+ ast_mutex_lock(&p->lock);
}
+
p->owner = NULL;
if (p->chan) {
ast_queue_hangup(p->chan);
diff --git a/main/channel.c b/main/channel.c
index 8490bbc2b..bd157acfa 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1982,25 +1982,22 @@ int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen,
int res = 0;
ast_channel_lock(chan);
-
if (chan->generatordata) {
if (chan->generator && chan->generator->release)
chan->generator->release(chan, chan->generatordata);
chan->generatordata = NULL;
}
-
- ast_prod(chan);
if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
res = -1;
}
-
if (!res) {
ast_settimeout(chan, 50, generator_force, chan);
chan->generator = gen;
}
-
ast_channel_unlock(chan);
+ ast_prod(chan);
+
return res;
}