#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
#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
if (res < 0)
ast_log(LOG_WARNING, "pri_disconnect failed\n");
tmp->pvt->rawwriteformat = deflaw;
tmp->writeformat = deflaw;
i->subs[index].linear = 0;
+ i->alreadyhungup = 0;
zt_setlinear(i->subs[index].zfd, i->subs[index].linear);
features = 0;
if (i->busydetect && CANBUSYDETECT(i)) {
break;
case PRI_EVENT_HANGUP:
chan = e->hangup.channel;
+ ast_log(LOG_NOTICE, "channel %d\n",chan);
if ((chan < 1) || (chan > pri->channels)) {
ast_log(LOG_WARNING, "Hangup requested on odd channel number %d span %d\n", chan, pri->span);
chan = 0;
chan = pri_fixup(pri, chan, e->hangup.call);
if (chan) {
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]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (option_verbose > 2)
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)
}
}
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 (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 REQ on bad channel %d\n", e->hangup.channel);
+ }
+ }
+ break;
case PRI_EVENT_HANGUP_ACK:
chan = e->hangup.channel;
if ((chan < 1) || (chan > pri->channels)) {