aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_zap.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-29 17:35:19 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-29 17:35:19 +0000
commit3db76e85a49901a2049ec3d430685d5c32f7aeba (patch)
treee50351cd486e0a7298a3de06f70964fe2b1de70b /channels/chan_zap.c
parentfbdb5ab9e626c212baf6ace1e347676e5cf46bf8 (diff)
Merged revisions 118953 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r118953 | tilghman | 2008-05-29 12:20:16 -0500 (Thu, 29 May 2008) | 3 lines Add some debugging code that ensures that when we do deadlock avoidance, we don't lose the information about how a lock was originally acquired. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@118955 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_zap.c')
-rw-r--r--channels/chan_zap.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index b9860f33a..6646ee2e1 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -882,10 +882,7 @@ static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *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 */
@@ -976,9 +973,7 @@ static void wakeup_sub(struct zt_pvt *p, int a, void *pri)
for (;;) {
if (p->subs[a].owner) {
if (ast_channel_trylock(p->subs[a].owner)) {
- ast_mutex_unlock(&p->lock);
- usleep(1);
- ast_mutex_lock(&p->lock);
+ DEADLOCK_AVOIDANCE(&p->lock);
} else {
ast_queue_frame(p->subs[a].owner, &ast_null_frame);
ast_channel_unlock(p->subs[a].owner);
@@ -1025,9 +1020,7 @@ static void zap_queue_frame(struct zt_pvt *p, struct ast_frame *f, void *data)
for (;;) {
if (p->owner) {
if (ast_channel_trylock(p->owner)) {
- ast_mutex_unlock(&p->lock);
- usleep(1);
- ast_mutex_lock(&p->lock);
+ DEADLOCK_AVOIDANCE(&p->lock);
} else {
ast_queue_frame(p->owner, f);
ast_channel_unlock(p->owner);
@@ -3643,9 +3636,7 @@ static void zt_unlink(struct zt_pvt *slave, struct zt_pvt *master, int needlock)
ast_mutex_lock(&master->lock);
if (slave) {
while (ast_mutex_trylock(&slave->lock)) {
- ast_mutex_unlock(&master->lock);
- usleep(1);
- ast_mutex_lock(&master->lock);
+ DEADLOCK_AVOIDANCE(&master->lock);
}
}
}
@@ -10128,9 +10119,7 @@ static int pri_hangup_all(struct zt_pvt *p, struct zt_pri *pri)
for (x = 0; x < 3; x++) {
while (p->subs[x].owner && ast_channel_trylock(p->subs[x].owner)) {
redo++;
- ast_mutex_unlock(&p->lock);
- usleep(1);
- ast_mutex_lock(&p->lock);
+ DEADLOCK_AVOIDANCE(&p->lock);
}
if (p->subs[x].owner) {
ast_queue_hangup_with_cause(p->subs[x].owner, AST_CAUSE_PRE_EMPTED);