[asterisk-commits] rmudgett: branch 1.8 r363687 - /branches/1.8/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 25 14:45:36 CDT 2012
Author: rmudgett
Date: Wed Apr 25 14:45:34 2012
New Revision: 363687
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=363687
Log:
Clear ISDN channel resetting state if the peer continues to use it.
Some ISDN switches occasionally fail to send a RESTART ACKNOWLEDGE in
response to a RESTART request.
* Made the second SETUP received after sending a RESTART request clear the
channel resetting state as if the peer had sent the expected RESTART
ACKNOWLEDGE before continuing to process the SETUP. The peer may not be
sending the expected RESTART ACKNOWLEDGE.
(issue ASTERISK-19608)
(issue AST-844)
(issue AST-815)
Patches:
jira_ast_815_v1.8.patch (license #5621) patch uploaded by rmudgett (modified)
Modified:
branches/1.8/channels/chan_dahdi.c
branches/1.8/channels/sig_pri.c
branches/1.8/channels/sig_pri.h
Modified: branches/1.8/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_dahdi.c?view=diff&rev=363687&r1=363686&r2=363687
==============================================================================
--- branches/1.8/channels/chan_dahdi.c (original)
+++ branches/1.8/channels/chan_dahdi.c Wed Apr 25 14:45:34 2012
@@ -15394,8 +15394,9 @@
struct sig_pri_chan *chan = tmp->sig_pvt;
ast_cli(a->fd, "PRI Flags: ");
- if (chan->resetting)
- ast_cli(a->fd, "Resetting ");
+ if (chan->resetting != SIG_PRI_RESET_IDLE) {
+ ast_cli(a->fd, "Resetting=%d ", chan->resetting);
+ }
if (chan->call)
ast_cli(a->fd, "Call ");
if (chan->allocated) {
Modified: branches/1.8/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sig_pri.c?view=diff&rev=363687&r1=363686&r2=363687
==============================================================================
--- branches/1.8/channels/sig_pri.c (original)
+++ branches/1.8/channels/sig_pri.c Wed Apr 25 14:45:34 2012
@@ -196,11 +196,11 @@
}
/*
- * Clear the channel restart flag when the channel alarm changes
- * to prevent the flag from getting stuck when the link goes
- * down.
+ * Clear the channel restart state when the channel alarm
+ * changes to prevent the state from getting stuck when the link
+ * goes down.
*/
- p->resetting = 0;
+ p->resetting = SIG_PRI_RESET_IDLE;
p->inalarm = in_alarm;
if (p->calls->set_alarm) {
@@ -1147,7 +1147,8 @@
*/
static int sig_pri_is_chan_in_use(struct sig_pri_chan *pvt)
{
- return pvt->owner || pvt->call || pvt->allocated || pvt->resetting || pvt->inalarm;
+ return pvt->owner || pvt->call || pvt->allocated || pvt->inalarm
+ || pvt->resetting != SIG_PRI_RESET_IDLE;
}
/*!
@@ -1709,7 +1710,7 @@
}
if (pri->resetpos < pri->numchans) {
/* Mark the channel as resetting and restart it */
- pri->pvts[pri->resetpos]->resetting = 1;
+ pri->pvts[pri->resetpos]->resetting = SIG_PRI_RESET_ACTIVE;
pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[pri->resetpos]));
} else {
pri->resetting = 0;
@@ -5099,13 +5100,40 @@
"Span %d: SETUP on unconfigured channel %d/%d\n",
pri->span, PRI_SPAN(e->ring.channel),
PRI_CHANNEL(e->ring.channel));
- } else if (!sig_pri_is_chan_available(pri->pvts[chanpos])) {
- /* This is where we handle initial glare */
- ast_debug(1,
- "Span %d: SETUP requested unavailable channel %d/%d. Attempting to renegotiate.\n",
- pri->span, PRI_SPAN(e->ring.channel),
- PRI_CHANNEL(e->ring.channel));
- chanpos = -1;
+ } else {
+ switch (pri->pvts[chanpos]->resetting) {
+ case SIG_PRI_RESET_IDLE:
+ break;
+ case SIG_PRI_RESET_ACTIVE:
+ /*
+ * The peer may have lost the expected ack or not received the
+ * RESTART yet.
+ */
+ pri->pvts[chanpos]->resetting = SIG_PRI_RESET_NO_ACK;
+ break;
+ case SIG_PRI_RESET_NO_ACK:
+ /* The peer likely is not going to ack the RESTART. */
+ ast_debug(1,
+ "Span %d: Second SETUP while waiting for RESTART ACKNOWLEDGE on channel %d/%d\n",
+ pri->span, PRI_SPAN(e->ring.channel),
+ PRI_CHANNEL(e->ring.channel));
+
+ /* Assume we got the ack. */
+ pri->pvts[chanpos]->resetting = SIG_PRI_RESET_IDLE;
+ if (pri->resetting) {
+ /* Go on to the next idle channel to RESTART. */
+ pri_check_restart(pri);
+ }
+ break;
+ }
+ if (!sig_pri_is_chan_available(pri->pvts[chanpos])) {
+ /* This is where we handle initial glare */
+ ast_debug(1,
+ "Span %d: SETUP requested unavailable channel %d/%d. Attempting to renegotiate.\n",
+ pri->span, PRI_SPAN(e->ring.channel),
+ PRI_CHANNEL(e->ring.channel));
+ chanpos = -1;
+ }
}
#if defined(ALWAYS_PICK_CHANNEL)
if (e->ring.flexible) {
@@ -5927,12 +5955,12 @@
#if defined(FORCE_RESTART_UNAVAIL_CHANS)
if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL
&& pri->sig != SIG_BRI_PTMP && !pri->resetting
- && !pri->pvts[chanpos]->resetting) {
+ && pri->pvts[chanpos]->resetting == SIG_PRI_RESET_IDLE) {
ast_verb(3,
"Span %d: Forcing restart of channel %d/%d since channel reported in use\n",
pri->span, pri->pvts[chanpos]->logicalspan,
pri->pvts[chanpos]->prioffset);
- pri->pvts[chanpos]->resetting = 1;
+ pri->pvts[chanpos]->resetting = SIG_PRI_RESET_ACTIVE;
pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
}
#endif /* defined(FORCE_RESTART_UNAVAIL_CHANS) */
@@ -6075,12 +6103,12 @@
#if defined(FORCE_RESTART_UNAVAIL_CHANS)
if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL
&& pri->sig != SIG_BRI_PTMP && !pri->resetting
- && !pri->pvts[chanpos]->resetting) {
+ && pri->pvts[chanpos]->resetting == SIG_PRI_RESET_IDLE) {
ast_verb(3,
"Span %d: Forcing restart of channel %d/%d since channel reported in use\n",
pri->span, pri->pvts[chanpos]->logicalspan,
pri->pvts[chanpos]->prioffset);
- pri->pvts[chanpos]->resetting = 1;
+ pri->pvts[chanpos]->resetting = SIG_PRI_RESET_ACTIVE;
pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
}
#endif /* defined(FORCE_RESTART_UNAVAIL_CHANS) */
@@ -6144,7 +6172,8 @@
channel number, so we have to figure it out... This must be why
everybody resets exactly a channel at a time. */
for (x = 0; x < pri->numchans; x++) {
- if (pri->pvts[x] && pri->pvts[x]->resetting) {
+ if (pri->pvts[x]
+ && pri->pvts[x]->resetting != SIG_PRI_RESET_IDLE) {
chanpos = x;
sig_pri_lock_private(pri->pvts[chanpos]);
ast_debug(1,
@@ -6158,7 +6187,7 @@
pri->pvts[chanpos]->prioffset);
pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
}
- pri->pvts[chanpos]->resetting = 0;
+ pri->pvts[chanpos]->resetting = SIG_PRI_RESET_IDLE;
ast_verb(3,
"Span %d: Channel %d/%d successfully restarted\n",
pri->span, pri->pvts[chanpos]->logicalspan,
@@ -6177,6 +6206,15 @@
}
} else {
sig_pri_lock_private(pri->pvts[chanpos]);
+ if (pri->pvts[chanpos]->resetting == SIG_PRI_RESET_IDLE) {
+ /* The channel is not in the resetting state. */
+ ast_debug(1,
+ "Span %d: Unexpected or late restart ack on channel %d/%d (Ignoring)\n",
+ pri->span, pri->pvts[chanpos]->logicalspan,
+ pri->pvts[chanpos]->prioffset);
+ sig_pri_unlock_private(pri->pvts[chanpos]);
+ break;
+ }
if (pri->pvts[chanpos]->owner) {
ast_log(LOG_WARNING,
"Span %d: Got restart ack on channel %d/%d with owner\n",
@@ -6184,7 +6222,7 @@
pri->pvts[chanpos]->prioffset);
pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
}
- pri->pvts[chanpos]->resetting = 0;
+ pri->pvts[chanpos]->resetting = SIG_PRI_RESET_IDLE;
ast_verb(3,
"Span %d: Channel %d/%d successfully restarted\n",
pri->span, pri->pvts[chanpos]->logicalspan,
Modified: branches/1.8/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sig_pri.h?view=diff&rev=363687&r1=363686&r2=363687
==============================================================================
--- branches/1.8/channels/sig_pri.h (original)
+++ branches/1.8/channels/sig_pri.h Wed Apr 25 14:45:34 2012
@@ -101,6 +101,27 @@
SIG_PRI_CALL_LEVEL_CONNECT,
};
+enum sig_pri_reset_state {
+ /*! \brief The channel is not being RESTARTed. */
+ SIG_PRI_RESET_IDLE,
+ /*!
+ * \brief The channel is being RESTARTed.
+ * \note Waiting for a RESTART ACKNOWLEDGE from the peer.
+ */
+ SIG_PRI_RESET_ACTIVE,
+ /*!
+ * \brief Peer may not be sending the expected RESTART ACKNOWLEDGE.
+ *
+ * \details We have already received a SETUP on this channel.
+ * If another SETUP comes in on this channel then the peer
+ * considers this channel useable. Assume that the peer is
+ * never going to give us a RESTART ACKNOWLEDGE and assume that
+ * we have received one. This is not according to Q.931, but
+ * some peers occasionally fail to send a RESTART ACKNOWLEDGE.
+ */
+ SIG_PRI_RESET_NO_ACK,
+};
+
struct sig_pri_span;
struct sig_pri_callback {
@@ -245,7 +266,6 @@
unsigned int alreadyhungup:1; /*!< TRUE if the call has already gone/hungup */
unsigned int isidlecall:1; /*!< TRUE if this is an idle call */
unsigned int progress:1; /*!< TRUE if the call has seen inband-information progress through the network */
- unsigned int resetting:1; /*!< TRUE if this channel is being reset/restarted */
/*!
* \brief TRUE when this channel is allocated.
@@ -274,6 +294,8 @@
/*! Call establishment life cycle level for simple comparisons. */
enum sig_pri_call_level call_level;
+ /*! \brief Channel reset/restart state. */
+ enum sig_pri_reset_state resetting;
int prioffset; /*!< channel number in span */
int logicalspan; /*!< logical span number within trunk group */
int mastertrunkgroup; /*!< what trunk group is our master */
More information about the asterisk-commits
mailing list