[asterisk-commits] rmudgett: branch 10 r363688 - in /branches/10: ./ channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 25 14:47:49 CDT 2012
Author: rmudgett
Date: Wed Apr 25 14:47:44 2012
New Revision: 363688
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=363688
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)
........
Merged revisions 363687 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/channels/chan_dahdi.c
branches/10/channels/sig_pri.c
branches/10/channels/sig_pri.h
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/chan_dahdi.c?view=diff&rev=363688&r1=363687&r2=363688
==============================================================================
--- branches/10/channels/chan_dahdi.c (original)
+++ branches/10/channels/chan_dahdi.c Wed Apr 25 14:47:44 2012
@@ -15507,8 +15507,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/10/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/sig_pri.c?view=diff&rev=363688&r1=363687&r2=363688
==============================================================================
--- branches/10/channels/sig_pri.c (original)
+++ branches/10/channels/sig_pri.c Wed Apr 25 14:47:44 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) {
@@ -1157,7 +1157,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;
}
/*!
@@ -1712,7 +1713,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;
@@ -5949,13 +5950,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) {
@@ -6776,12 +6804,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) */
@@ -6924,12 +6952,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) */
@@ -6993,7 +7021,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,
@@ -7007,7 +7036,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,
@@ -7026,6 +7055,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",
@@ -7033,7 +7071,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/10/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/sig_pri.h?view=diff&rev=363688&r1=363687&r2=363688
==============================================================================
--- branches/10/channels/sig_pri.h (original)
+++ branches/10/channels/sig_pri.h Wed Apr 25 14:47:44 2012
@@ -162,6 +162,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 {
@@ -311,7 +332,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.
@@ -340,6 +360,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