Use ast_channel_lock_both() where it was inlined before.

The CHANNEL_DEADLOCK_AVOIDANCE() feature of preserving where the channel
lock was originally obtained is overkill where ast_channel_lock_both() was
inlined.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/11.2
Richard Mudgett 13 years ago
parent b43f4a60dd
commit 01194c5811

@ -902,15 +902,13 @@ static void do_forward(struct chanlist *o,
} else { } else {
struct ast_party_redirecting redirecting; struct ast_party_redirecting redirecting;
ast_channel_lock_both(c, in);
if (single_caller_bored && CAN_EARLY_BRIDGE(peerflags, c, in)) { if (single_caller_bored && CAN_EARLY_BRIDGE(peerflags, c, in)) {
ast_rtp_instance_early_bridge_make_compatible(c, in); ast_rtp_instance_early_bridge_make_compatible(c, in);
} }
ast_channel_set_redirecting(c, ast_channel_redirecting(original), NULL); ast_channel_set_redirecting(c, ast_channel_redirecting(original), NULL);
ast_channel_lock(c);
while (ast_channel_trylock(in)) {
CHANNEL_DEADLOCK_AVOIDANCE(c);
}
if (!ast_channel_redirecting(c)->from.number.valid if (!ast_channel_redirecting(c)->from.number.valid
|| ast_strlen_zero(ast_channel_redirecting(c)->from.number.str)) { || ast_strlen_zero(ast_channel_redirecting(c)->from.number.str)) {
/* /*
@ -986,10 +984,7 @@ static void do_forward(struct chanlist *o,
c = o->chan = NULL; c = o->chan = NULL;
num->nochan++; num->nochan++;
} else { } else {
ast_channel_lock(c); ast_channel_lock_both(c, in);
while (ast_channel_trylock(in)) {
CHANNEL_DEADLOCK_AVOIDANCE(c);
}
senddialevent(in, c, stuff); senddialevent(in, c, stuff);
ast_channel_unlock(in); ast_channel_unlock(in);
ast_channel_unlock(c); ast_channel_unlock(c);
@ -2295,10 +2290,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
} }
pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst); pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);
ast_channel_lock(tc); ast_channel_lock_both(tc, chan);
while (ast_channel_trylock(chan)) {
CHANNEL_DEADLOCK_AVOIDANCE(tc);
}
/* Setup outgoing SDP to match incoming one */ /* Setup outgoing SDP to match incoming one */
if (!outgoing && !rest && CAN_EARLY_BRIDGE(peerflags, chan, tc)) { if (!outgoing && !rest && CAN_EARLY_BRIDGE(peerflags, chan, tc)) {
ast_rtp_instance_early_bridge_make_compatible(tc, chan); ast_rtp_instance_early_bridge_make_compatible(tc, chan);

@ -7302,10 +7302,7 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1)) if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))
return AST_BRIDGE_FAILED_NOWARN; return AST_BRIDGE_FAILED_NOWARN;
ast_channel_lock(c0); ast_channel_lock_both(c0, c1);
while (ast_channel_trylock(c1)) {
CHANNEL_DEADLOCK_AVOIDANCE(c0);
}
p0 = ast_channel_tech_pvt(c0); p0 = ast_channel_tech_pvt(c0);
p1 = ast_channel_tech_pvt(c1); p1 = ast_channel_tech_pvt(c1);
@ -7513,10 +7510,7 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
/* Here's our main loop... Start by locking things, looking for private parts, /* Here's our main loop... Start by locking things, looking for private parts,
and then balking if anything is wrong */ and then balking if anything is wrong */
ast_channel_lock(c0); ast_channel_lock_both(c0, c1);
while (ast_channel_trylock(c1)) {
CHANNEL_DEADLOCK_AVOIDANCE(c0);
}
p0 = ast_channel_tech_pvt(c0); p0 = ast_channel_tech_pvt(c0);
p1 = ast_channel_tech_pvt(c1); p1 = ast_channel_tech_pvt(c1);

@ -194,10 +194,7 @@ static void awesome_locking(struct local_pvt *p, struct ast_channel **outchan, s
ao2_lock(p); ao2_lock(p);
} else { } else {
/* lock both channels first, then get the pvt lock */ /* lock both channels first, then get the pvt lock */
ast_channel_lock(chan); ast_channel_lock_both(chan, owner);
while (ast_channel_trylock(owner)) {
CHANNEL_DEADLOCK_AVOIDANCE(chan);
}
ao2_lock(p); ao2_lock(p);
} }

@ -8560,10 +8560,7 @@ static int misdn_attempt_transfer(struct chan_list *active_ch, struct chan_list
return -1; return -1;
} }
ast_channel_lock(held_ch->ast); ast_channel_lock_both(held_ch->ast, active_ch->ast);
while (ast_channel_trylock(active_ch->ast)) {
CHANNEL_DEADLOCK_AVOIDANCE(held_ch->ast);
}
transferee = ast_bridged_channel(held_ch->ast); transferee = ast_bridged_channel(held_ch->ast);
if (!transferee) { if (!transferee) {

@ -1452,12 +1452,7 @@ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struc
int res = 0; int res = 0;
/* Lock both channels so we can look for the glue that binds them together */ /* Lock both channels so we can look for the glue that binds them together */
ast_channel_lock(c0); ast_channel_lock_both(c0, c1);
while (ast_channel_trylock(c1)) {
ast_channel_unlock(c0);
usleep(1);
ast_channel_lock(c0);
}
if (!cap1 || !cap0) { if (!cap1 || !cap0) {
goto done; goto done;

Loading…
Cancel
Save