aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_zap.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-05 16:44:21 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-05 16:44:21 +0000
commitf5b7c9fa275967fd8ec23bb5f46feca3f7938cac (patch)
tree855bb2747b9987b50ff267bbc959da36bb2b3385 /channels/chan_zap.c
parentb9342faad5ae073b84791e986b88788cb340cf66 (diff)
Do deadlock avoidance in a couple more places. You can't lock two channels
at the same time without doing extra work to make sure it succeeds. (closes issue #10895, patch by me) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@84783 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_zap.c')
-rw-r--r--channels/chan_zap.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index f490c047a..90dae4345 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -3167,7 +3167,11 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
return AST_BRIDGE_FAILED_NOWARN;
ast_mutex_lock(&c0->lock);
- ast_mutex_lock(&c1->lock);
+ while (ast_mutex_trylock(&c1->lock)) {
+ ast_mutex_unlock(&c0->lock);
+ usleep(1);
+ ast_mutex_lock(&c0->lock);
+ }
p0 = c0->tech_pvt;
p1 = c1->tech_pvt;
@@ -3335,7 +3339,12 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
/* Here's our main loop... Start by locking things, looking for private parts,
and then balking if anything is wrong */
ast_mutex_lock(&c0->lock);
- ast_mutex_lock(&c1->lock);
+ while (ast_mutex_trylock(&c1->lock)) {
+ ast_mutex_unlock(&c0->lock);
+ usleep(1);
+ ast_mutex_lock(&c0->lock);
+ }
+
p0 = c0->tech_pvt;
p1 = c1->tech_pvt;