|
|
|
@ -722,10 +722,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 */
|
|
|
|
@ -792,9 +789,7 @@ static void wakeup_sub(struct zt_pvt *p, int a, void *pri)
|
|
|
|
|
for (;;) {
|
|
|
|
|
if (p->subs[a].owner) {
|
|
|
|
|
if (ast_mutex_trylock(&p->subs[a].owner->lock)) {
|
|
|
|
|
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_mutex_unlock(&p->subs[a].owner->lock);
|
|
|
|
@ -823,9 +818,7 @@ static void zap_queue_frame(struct zt_pvt *p, struct ast_frame *f, void *pri)
|
|
|
|
|
for (;;) {
|
|
|
|
|
if (p->owner) {
|
|
|
|
|
if (ast_mutex_trylock(&p->owner->lock)) {
|
|
|
|
|
ast_mutex_unlock(&p->lock);
|
|
|
|
|
usleep(1);
|
|
|
|
|
ast_mutex_lock(&p->lock);
|
|
|
|
|
DEADLOCK_AVOIDANCE(&p->lock);
|
|
|
|
|
} else {
|
|
|
|
|
ast_queue_frame(p->owner, f);
|
|
|
|
|
ast_mutex_unlock(&p->owner->lock);
|
|
|
|
@ -3038,9 +3031,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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -3177,9 +3168,7 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
|
|
|
|
|
|
|
|
|
|
ast_mutex_lock(&c0->lock);
|
|
|
|
|
while (ast_mutex_trylock(&c1->lock)) {
|
|
|
|
|
ast_mutex_unlock(&c0->lock);
|
|
|
|
|
usleep(1);
|
|
|
|
|
ast_mutex_lock(&c0->lock);
|
|
|
|
|
DEADLOCK_AVOIDANCE(&c0->lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p0 = c0->tech_pvt;
|
|
|
|
@ -3349,9 +3338,7 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
|
|
|
|
|
and then balking if anything is wrong */
|
|
|
|
|
ast_mutex_lock(&c0->lock);
|
|
|
|
|
while (ast_mutex_trylock(&c1->lock)) {
|
|
|
|
|
ast_mutex_unlock(&c0->lock);
|
|
|
|
|
usleep(1);
|
|
|
|
|
ast_mutex_lock(&c0->lock);
|
|
|
|
|
DEADLOCK_AVOIDANCE(&c0->lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p0 = c0->tech_pvt;
|
|
|
|
@ -3910,12 +3897,10 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
|
|
|
|
|
while (p->subs[SUB_THREEWAY].owner && ast_mutex_trylock(&p->subs[SUB_THREEWAY].owner->lock)) {
|
|
|
|
|
/* Yuck, didn't get the lock on the 3-way, gotta release everything and re-grab! */
|
|
|
|
|
ast_mutex_unlock(&p->lock);
|
|
|
|
|
ast_mutex_unlock(&ast->lock);
|
|
|
|
|
usleep(1);
|
|
|
|
|
DEADLOCK_AVOIDANCE(&ast->lock);
|
|
|
|
|
/* 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_mutex_lock(&ast->lock);
|
|
|
|
|
ast_mutex_lock(&p->lock);
|
|
|
|
|
if (p->owner != ast) {
|
|
|
|
|
ast_log(LOG_WARNING, "This isn't good...\n");
|
|
|
|
@ -8301,9 +8286,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_mutex_trylock(&p->subs[x].owner->lock)) {
|
|
|
|
|
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(p->subs[x].owner);
|
|
|
|
|