summaryrefslogtreecommitdiff
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-05-29 17:35:19 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-05-29 17:35:19 +0000
commit6e5d843a719d87dc2b3833347fde404c4c228b77 (patch)
treee50351cd486e0a7298a3de06f70964fe2b1de70b /channels/chan_iax2.c
parent9a535bd115207d8e5e721336fde015642c562dd0 (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: https://origsvn.digium.com/svn/asterisk/trunk@118955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 7ce45d3c4..174a05a28 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1746,9 +1746,7 @@ static int iax2_queue_frame(int callno, struct ast_frame *f)
if (iaxs[callno] && iaxs[callno]->owner) {
if (ast_channel_trylock(iaxs[callno]->owner)) {
/* Avoid deadlock by pausing and trying again */
- ast_mutex_unlock(&iaxsl[callno]);
- usleep(1);
- ast_mutex_lock(&iaxsl[callno]);
+ DEADLOCK_AVOIDANCE(&iaxsl[callno]);
} else {
ast_queue_frame(iaxs[callno]->owner, f);
ast_channel_unlock(iaxs[callno]->owner);
@@ -1779,9 +1777,7 @@ static int iax2_queue_hangup(int callno)
if (iaxs[callno] && iaxs[callno]->owner) {
if (ast_channel_trylock(iaxs[callno]->owner)) {
/* Avoid deadlock by pausing and trying again */
- ast_mutex_unlock(&iaxsl[callno]);
- usleep(1);
- ast_mutex_lock(&iaxsl[callno]);
+ DEADLOCK_AVOIDANCE(&iaxsl[callno]);
} else {
ast_queue_hangup(iaxs[callno]->owner);
ast_channel_unlock(iaxs[callno]->owner);
@@ -1813,9 +1809,7 @@ static int iax2_queue_control_data(int callno,
if (iaxs[callno] && iaxs[callno]->owner) {
if (ast_channel_trylock(iaxs[callno]->owner)) {
/* Avoid deadlock by pausing and trying again */
- ast_mutex_unlock(&iaxsl[callno]);
- usleep(1);
- ast_mutex_lock(&iaxsl[callno]);
+ DEADLOCK_AVOIDANCE(&iaxsl[callno]);
} else {
ast_queue_control_data(iaxs[callno]->owner, control, data, datalen);
ast_channel_unlock(iaxs[callno]->owner);
@@ -3773,9 +3767,7 @@ static void lock_both(unsigned short callno0, unsigned short callno1)
{
ast_mutex_lock(&iaxsl[callno0]);
while (ast_mutex_trylock(&iaxsl[callno1])) {
- ast_mutex_unlock(&iaxsl[callno0]);
- usleep(10);
- ast_mutex_lock(&iaxsl[callno0]);
+ DEADLOCK_AVOIDANCE(&iaxsl[callno0]);
}
}
@@ -3969,9 +3961,7 @@ static int iax2_indicate(struct ast_channel *c, int condition, const void *data,
/* We don't know the remote side's call number, yet. :( */
int count = 10;
while (count-- && pvt && !pvt->peercallno) {
- ast_mutex_unlock(&iaxsl[callno]);
- usleep(1);
- ast_mutex_lock(&iaxsl[callno]);
+ DEADLOCK_AVOIDANCE(&iaxsl[callno]);
pvt = iaxs[callno];
}
if (!pvt->peercallno) {
@@ -8284,9 +8274,7 @@ static int socket_process(struct iax2_thread *thread)
int orignative;
retryowner:
if (ast_channel_trylock(iaxs[fr->callno]->owner)) {
- ast_mutex_unlock(&iaxsl[fr->callno]);
- usleep(1);
- ast_mutex_lock(&iaxsl[fr->callno]);
+ DEADLOCK_AVOIDANCE(&iaxsl[fr->callno]);
if (iaxs[fr->callno] && iaxs[fr->callno]->owner) goto retryowner;
}
if (iaxs[fr->callno]) {
@@ -8728,9 +8716,7 @@ retryowner:
ast_verb(3, "Format for call is %s\n", ast_getformatname(iaxs[fr->callno]->owner->nativeformats));
retryowner2:
if (ast_channel_trylock(iaxs[fr->callno]->owner)) {
- ast_mutex_unlock(&iaxsl[fr->callno]);
- usleep(1);
- ast_mutex_lock(&iaxsl[fr->callno]);
+ DEADLOCK_AVOIDANCE(&iaxsl[fr->callno]);
if (iaxs[fr->callno] && iaxs[fr->callno]->owner) goto retryowner2;
}