summaryrefslogtreecommitdiff
path: root/channels/chan_dahdi.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-06-25 02:34:11 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-06-25 02:34:11 +0000
commit94c4089f4eebc7c28346f97265119d238a92afbe (patch)
tree5b9f31de4abfe65b58eab4424d3e6556492634ee /channels/chan_dahdi.c
parent15093f2a63eb32e45ce42b6e00b14211d611e999 (diff)
More expansion of the deadlock avoidance macro, including a macro to do locking
of the channel lock git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125020 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_dahdi.c')
-rw-r--r--channels/chan_dahdi.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 54d8b4357..0050d6cbf 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -898,10 +898,7 @@ static inline int ss7_grab(struct dahdi_pvt *pvt, struct dahdi_ss7 *pri)
do {
res = ast_mutex_trylock(&pri->lock);
if (res) {
- ast_mutex_unlock(&pvt->lock);
- /* Release the lock and try again */
- usleep(1);
- ast_mutex_lock(&pvt->lock);
+ DEADLOCK_AVOIDANCE(&pvt->lock);
}
} while (res);
/* Then break the poll */
@@ -3755,9 +3752,7 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
ast_channel_lock(c0);
while (ast_channel_trylock(c1)) {
- ast_channel_unlock(c0);
- usleep(1);
- ast_channel_lock(c0);
+ CHANNEL_DEADLOCK_AVOIDANCE(c0);
}
p0 = c0->tech_pvt;
@@ -3927,9 +3922,7 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
ast_channel_lock(c0);
while (ast_channel_trylock(c1)) {
- ast_channel_unlock(c0);
- usleep(1);
- ast_channel_lock(c0);
+ CHANNEL_DEADLOCK_AVOIDANCE(c0);
}
p0 = c0->tech_pvt;
@@ -4469,14 +4462,12 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
the private structure -- not especially easy or clean */
while (p->subs[SUB_THREEWAY].owner && ast_channel_trylock(p->subs[SUB_THREEWAY].owner)) {
/* Yuck, didn't get the lock on the 3-way, gotta release everything and re-grab! */
- ast_mutex_unlock(&p->lock);
- ast_channel_unlock(ast);
- usleep(1);
+ DLA_UNLOCK(&p->lock);
+ CHANNEL_DEADLOCK_AVOIDANCE(ast);
/* We can grab ast and p in that order, without worry. We should make sure
nothing seriously bad has happened though like some sort of bizarre double
masquerade! */
- ast_channel_lock(ast);
- ast_mutex_lock(&p->lock);
+ DLA_LOCK(&p->lock);
if (p->owner != ast) {
ast_log(LOG_WARNING, "This isn't good...\n");
return NULL;