Add handling of PRI_EVENT_HANGUP_REQ

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1267 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Martin Pycko
2003-08-07 00:47:27 +00:00
parent e0369d78c9
commit 5e39502200

View File

@@ -1626,7 +1626,13 @@ static int zt_hangup(struct ast_channel *ast)
#ifndef PRI_HANGUP #ifndef PRI_HANGUP
#error Please update libpri. The new hangup routines were implemented. You can debug then using "pri debug span <span_no>". If you dont want to update libpri code simply comment out OPTIONS += -DNEW_PRI_HANGUP in asterisk/Makefile #error Please update libpri. The new hangup routines were implemented. You can debug then using "pri debug span <span_no>". If you dont want to update libpri code simply comment out OPTIONS += -DNEW_PRI_HANGUP in asterisk/Makefile
#endif #endif
pri_hangup(p->pri->pri, p->call, -1); if (p->alreadyhungup) {
pri_hangup(p->pri->pri, p->call, -1);
p->call = NULL;
} else {
p->alreadyhungup = 1;
pri_hangup(p->pri->pri, p->call, -1);
}
#endif #endif
if (res < 0) if (res < 0)
ast_log(LOG_WARNING, "pri_disconnect failed\n"); ast_log(LOG_WARNING, "pri_disconnect failed\n");
@@ -3532,6 +3538,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
tmp->pvt->rawwriteformat = deflaw; tmp->pvt->rawwriteformat = deflaw;
tmp->writeformat = deflaw; tmp->writeformat = deflaw;
i->subs[index].linear = 0; i->subs[index].linear = 0;
i->alreadyhungup = 0;
zt_setlinear(i->subs[index].zfd, i->subs[index].linear); zt_setlinear(i->subs[index].zfd, i->subs[index].linear);
features = 0; features = 0;
if (i->busydetect && CANBUSYDETECT(i)) { if (i->busydetect && CANBUSYDETECT(i)) {
@@ -5823,6 +5830,7 @@ static void *pri_dchannel(void *vpri)
break; break;
case PRI_EVENT_HANGUP: case PRI_EVENT_HANGUP:
chan = e->hangup.channel; chan = e->hangup.channel;
ast_log(LOG_NOTICE, "channel %d\n",chan);
if ((chan < 1) || (chan > pri->channels)) { if ((chan < 1) || (chan > pri->channels)) {
ast_log(LOG_WARNING, "Hangup requested on odd channel number %d span %d\n", chan, pri->span); ast_log(LOG_WARNING, "Hangup requested on odd channel number %d span %d\n", chan, pri->span);
chan = 0; chan = 0;
@@ -5834,11 +5842,48 @@ static void *pri_dchannel(void *vpri)
chan = pri_fixup(pri, chan, e->hangup.call); chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) { if (chan) {
ast_pthread_mutex_lock(&pri->pvt[chan]->lock); ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
if (pri->pvt[chan]->owner) { if (!pri->pvt[chan]->alreadyhungup) {
/* we're calling here zt_hangup so once we get there we need to clear p->call after calling pri_hangup */
pri->pvt[chan]->alreadyhungup = 1; pri->pvt[chan]->alreadyhungup = 1;
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV; pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Channel %d, span %d got hangup\n", chan, pri->span); ast_verbose(VERBOSE_PREFIX_3 "Channel %d, span %d got hangup\n", chan, pri->span);
} else {
pri_hangup(pri->pri, pri->pvt[chan]->call, e->hangup.cause);
pri->pvt[chan]->call = NULL;
}
if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Forcing restart of channel %d since channel reported in use\n", chan);
pri_reset(pri->pri, chan);
pri->pvt[chan]->resetting = 1;
}
ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
} else {
ast_log(LOG_WARNING, "Hangup on bad channel %d\n", e->hangup.channel);
}
}
break;
#ifndef PRI_EVENT_HANGUP_REQ
#error please update libpri
#endif
case PRI_EVENT_HANGUP_REQ:
chan = e->hangup.channel;
if ((chan < 1) || (chan > pri->channels)) {
ast_log(LOG_WARNING, "Hangup REQ requested on odd channel number %d span %d\n", chan, pri->span);
chan = 0;
} else if (!pri->pvt[chan]) {
ast_log(LOG_WARNING, "Hangup REQ requested on unconfigured channel %d span %d\n", chan, pri->span);
chan = 0;
}
if (chan) {
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
ast_pthread_mutex_lock(&pri->pvt[chan]->lock);
if (pri->pvt[chan]->owner) {
pri->pvt[chan]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Channel %d, span %d got hangup\n", chan, pri->span);
} }
if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) { if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) {
if (option_verbose > 2) if (option_verbose > 2)
@@ -5848,7 +5893,7 @@ static void *pri_dchannel(void *vpri)
} }
ast_pthread_mutex_unlock(&pri->pvt[chan]->lock); ast_pthread_mutex_unlock(&pri->pvt[chan]->lock);
} else { } else {
ast_log(LOG_WARNING, "Hangup on bad channel %d\n", e->hangup.channel); ast_log(LOG_WARNING, "Hangup REQ on bad channel %d\n", e->hangup.channel);
} }
} }
break; break;