[asterisk-commits] jpeeler: branch dhubbard/pinecowbell r185060 - /team/dhubbard/pinecowbell/cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 30 11:24:41 CDT 2009


Author: jpeeler
Date: Mon Mar 30 11:24:33 2009
New Revision: 185060

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=185060
Log:
Ensure that an out of service channel does not send any restart messages


Modified:
    team/dhubbard/pinecowbell/channels/chan_dahdi.c

Modified: team/dhubbard/pinecowbell/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/dhubbard/pinecowbell/channels/chan_dahdi.c?view=diff&rev=185060&r1=185059&r2=185060
==============================================================================
--- team/dhubbard/pinecowbell/channels/chan_dahdi.c (original)
+++ team/dhubbard/pinecowbell/channels/chan_dahdi.c Mon Mar 30 11:24:33 2009
@@ -10691,6 +10691,7 @@
 
 static int pri_check_restart(struct dahdi_pri *pri)
 {
+tryanotherpos:
 	do {
 		pri->resetpos++;
 	} while ((pri->resetpos < pri->numchans) &&
@@ -10698,6 +10699,24 @@
 		  pri->pvts[pri->resetpos]->call ||
 		  pri->pvts[pri->resetpos]->resetting));
 	if (pri->resetpos < pri->numchans) {
+		char db_chan_name[20], db_answer[5], state;
+		int why;
+
+		/* check if the channel is out of service */
+		ast_mutex_lock(&pri->pvts[pri->resetpos]->lock);
+		snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, pri->pvts[pri->resetpos]->channel);
+		ast_mutex_unlock(&pri->pvts[pri->resetpos]->lock);
+
+		/* if so, try next channel */
+		if (!ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
+			sscanf(db_answer, "%c:%d", &state, &why);
+			if (why) {
+				ast_log(LOG_NOTICE, "span '%d' channel '%d' out-of-service (reason: %s), not sending RESTART\n", pri->span,
+				pri->pvts[pri->resetpos]->channel, (why & SRVST_FAREND) ? (why & SRVST_NEAREND) ? "both ends" : "far end" : "near end");
+				goto tryanotherpos;
+			}
+		}
+
 		/* Mark the channel as resetting and restart it */
 		pri->pvts[pri->resetpos]->resetting = 1;
 		pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[pri->resetpos]));




More information about the asterisk-commits mailing list