mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
Fix a deadlock in d-channel handling in chan_zap.
This deadlock was introduced by the fix to ensure that channels are properly locked when handling channel variables. There were sections of this code where the channel pvt was locked before the channel lock, when in fact it _must_ be the other way around. (closes issue #11582) Reported by: bugi git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@94251 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -8813,6 +8813,9 @@ static void *pri_dchannel(void *vpri)
|
||||
} else {
|
||||
c = zt_new(pri->pvts[chanpos], AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
|
||||
}
|
||||
|
||||
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
|
||||
|
||||
if (!ast_strlen_zero(e->ring.callingsubaddr)) {
|
||||
pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", e->ring.callingsubaddr);
|
||||
}
|
||||
@@ -8831,8 +8834,10 @@ static void *pri_dchannel(void *vpri)
|
||||
pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
|
||||
if (e->ring.redirectingreason >= 0)
|
||||
pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason));
|
||||
|
||||
|
||||
ast_mutex_lock(&pri->pvts[chanpos]->lock);
|
||||
ast_mutex_lock(&pri->lock);
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
|
||||
@@ -8855,9 +8860,11 @@ static void *pri_dchannel(void *vpri)
|
||||
ast_mutex_unlock(&pri->lock);
|
||||
/* Release PRI lock while we create the channel */
|
||||
c = zt_new(pri->pvts[chanpos], AST_STATE_RING, 1, SUB_REAL, law, e->ring.ctype);
|
||||
ast_mutex_lock(&pri->lock);
|
||||
if (c) {
|
||||
char calledtonstr[10];
|
||||
|
||||
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
|
||||
|
||||
if (e->ring.ani2 >= 0) {
|
||||
snprintf(ani2str, 5, "%d", e->ring.ani2);
|
||||
pbx_builtin_setvar_helper(c, "ANI2", ani2str);
|
||||
@@ -8874,12 +8881,19 @@ static void *pri_dchannel(void *vpri)
|
||||
|
||||
snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
|
||||
pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
|
||||
|
||||
ast_mutex_lock(&pri->pvts[chanpos]->lock);
|
||||
ast_mutex_lock(&pri->lock);
|
||||
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting call from '%s' to '%s' on channel %d/%d, span %d\n",
|
||||
plancallingnum, pri->pvts[chanpos]->exten,
|
||||
pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
|
||||
zt_enable_ec(pri->pvts[chanpos]);
|
||||
} else {
|
||||
|
||||
ast_mutex_lock(&pri->lock);
|
||||
|
||||
ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n",
|
||||
pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
|
||||
pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
|
||||
@@ -8938,7 +8952,10 @@ static void *pri_dchannel(void *vpri)
|
||||
|
||||
#ifdef SUPPORT_USERUSER
|
||||
if (!ast_strlen_zero(e->ringing.useruserinfo)) {
|
||||
struct ast_channel *owner = pri->pvts[chanpos]->owner;
|
||||
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
|
||||
pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->ringing.useruserinfo);
|
||||
ast_mutex_lock(&pri->pvts[chanpos]->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9093,7 +9110,10 @@ static void *pri_dchannel(void *vpri)
|
||||
|
||||
#ifdef SUPPORT_USERUSER
|
||||
if (!ast_strlen_zero(e->answer.useruserinfo)) {
|
||||
struct ast_channel *owner = pri->pvts[chanpos]->owner;
|
||||
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
|
||||
pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->answer.useruserinfo);
|
||||
ast_mutex_lock(&pri->pvts[chanpos]->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9159,7 +9179,10 @@ static void *pri_dchannel(void *vpri)
|
||||
|
||||
#ifdef SUPPORT_USERUSER
|
||||
if (pri->pvts[chanpos]->owner && !ast_strlen_zero(e->hangup.useruserinfo)) {
|
||||
struct ast_channel *owner = pri->pvts[chanpos]->owner;
|
||||
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
|
||||
pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->hangup.useruserinfo);
|
||||
ast_mutex_lock(&pri->pvts[chanpos]->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9225,7 +9248,10 @@ static void *pri_dchannel(void *vpri)
|
||||
|
||||
#ifdef SUPPORT_USERUSER
|
||||
if (!ast_strlen_zero(e->hangup.useruserinfo)) {
|
||||
struct ast_channel *owner = pri->pvts[chanpos]->owner;
|
||||
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
|
||||
pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->hangup.useruserinfo);
|
||||
ast_mutex_lock(&pri->pvts[chanpos]->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9253,7 +9279,10 @@ static void *pri_dchannel(void *vpri)
|
||||
|
||||
#ifdef SUPPORT_USERUSER
|
||||
if (!ast_strlen_zero(e->hangup.useruserinfo)) {
|
||||
struct ast_channel *owner = pri->pvts[chanpos]->owner;
|
||||
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
|
||||
pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->hangup.useruserinfo);
|
||||
ast_mutex_lock(&pri->pvts[chanpos]->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user