aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-09 15:41:28 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-09 15:41:28 +0000
commit3c820260af075ec2c011af624a6ec8b65b673973 (patch)
treeab462c0ecf33db711c179736f84594372ac34e00 /channels
parent8b4ba0cd8056684c581ba8488f80bbdd54779d68 (diff)
Properly avoid a collision with iax2_hangup (issue #8115 reported by vazir)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@44759 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 1a299675c..1b6b62db2 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1688,13 +1688,10 @@ static void iax2_destroy_helper(struct chan_iax2_pvt *pvt)
static int iax2_predestroy(int callno)
{
struct ast_channel *c;
- struct chan_iax2_pvt *pvt;
- ast_mutex_lock(&iaxsl[callno]);
- pvt = iaxs[callno];
- if (!pvt) {
- ast_mutex_unlock(&iaxsl[callno]);
+ struct chan_iax2_pvt *pvt = iaxs[callno];
+
+ if (!pvt)
return -1;
- }
if (!ast_test_flag(pvt, IAX_ALREADYGONE)) {
iax2_destroy_helper(pvt);
ast_set_flag(pvt, IAX_ALREADYGONE);
@@ -1708,19 +1705,16 @@ static int iax2_predestroy(int callno)
ast_atomic_fetchadd_int(&usecnt, -1);
ast_update_use_count();
}
- ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
static void iax2_destroy(int callno)
{
- struct chan_iax2_pvt *pvt;
+ struct chan_iax2_pvt *pvt = iaxs[callno];
struct iax_frame *cur;
struct ast_channel *owner;
retry:
- ast_mutex_lock(&iaxsl[callno]);
- pvt = iaxs[callno];
gettimeofday(&lastused[callno], NULL);
owner = pvt ? pvt->owner : NULL;
@@ -1730,6 +1724,7 @@ retry:
ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
+ ast_mutex_lock(&iaxsl[callno]);
goto retry;
}
}
@@ -1774,7 +1769,6 @@ retry:
if (owner) {
ast_mutex_unlock(&owner->lock);
}
- ast_mutex_unlock(&iaxsl[callno]);
if (callno & 0x4000)
update_max_trunk();
}