diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-29 17:42:28 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-29 17:42:28 +0000 |
commit | 5f08a3ee3a2125e69352c5404d7f57bed9b480f6 (patch) | |
tree | 1423c2f41c452512d73905e0542e62bb6c598735 /channels/chan_iax2.c | |
parent | 119443fc3f48cf7d749e58ea9c7d47af6511a3b4 (diff) |
Merged revisions 118955,118957 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r118955 | tilghman | 2008-05-29 12:35:19 -0500 (Thu, 29 May 2008) | 11 lines
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.
........
................
r118957 | tilghman | 2008-05-29 12:39:50 -0500 (Thu, 29 May 2008) | 10 lines
Merged revisions 118954 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r118954 | tilghman | 2008-05-29 12:33:01 -0500 (Thu, 29 May 2008) | 2 lines
Define also when not DEBUG_THREADS
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@118958 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 772491111..7e1822557 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1734,9 +1734,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); @@ -1767,9 +1765,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); @@ -1801,9 +1797,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); @@ -3734,9 +3728,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]); } } @@ -3927,9 +3919,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) { @@ -8220,9 +8210,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]) { @@ -8659,9 +8647,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; } |