[Asterisk-cvs] asterisk/channels chan_zap.c,1.255,1.256

markster at lists.digium.com markster at lists.digium.com
Mon Jun 7 10:54:42 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv2849/channels

Modified Files:
	chan_zap.c 
Log Message:
More GR-303 protocol fixes


Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.255
retrieving revision 1.256
diff -u -d -r1.255 -r1.256
--- chan_zap.c	7 Jun 2004 14:49:25 -0000	1.255
+++ chan_zap.c	7 Jun 2004 15:57:18 -0000	1.256
@@ -6589,6 +6589,7 @@
 	struct zt_pri *pri = vpri;
 	pri_event *e;
 	struct pollfd fds[NUM_DCHANS];
+	struct zt_spaninfo si;
 	int res;
 	int chanpos = 0;
 	int x;
@@ -6719,7 +6720,7 @@
 			/* Find lowest available d-channel */
 			if (!pri->dchannels[i])
 				break;
-			if ((next = pri_schedule_next(pri->pri))) {
+			if ((next = pri_schedule_next(pri->dchans[i]))) {
 				/* We need relative time here */
 				gettimeofday(&tv, NULL);
 				tv.tv_sec = next->tv_sec - tv.tv_sec;
@@ -6777,7 +6778,24 @@
 			for (which=0;which<NUM_DCHANS;which++) {
 				if (!pri->dchans[which])
 					break;
-				if (fds[which].revents & (POLLIN | POLLPRI)) {
+				if (fds[which].revents & POLLPRI) {
+					/* Check for an event */
+					x = 0;
+					res = ioctl(pri->fds[which], ZT_GETEVENT, &x);
+					if (x) 
+						ast_log(LOG_NOTICE, "PRI got event: %d on %s D-channel of span %d\n", x, pri_order(which), pri->span);
+					/* Keep track of alarm state */	
+					if (x == ZT_EVENT_ALARM) {
+						pri->dchanavail[which] &= ~(DCHAN_NOTINALARM | DCHAN_UP);
+						pri_find_dchan(pri);
+					} else if (x == ZT_EVENT_NOALARM) {
+						pri->dchanavail[which] |= DCHAN_NOTINALARM;
+						pri_find_dchan(pri);
+					}
+				
+					if (option_debug)
+						ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
+				} else if (fds[which].revents & POLLIN) {
 					e = pri_check_event(pri->dchans[which]);
 				}
 				if (e)
@@ -7351,28 +7369,6 @@
 			default:
 				ast_log(LOG_DEBUG, "Event: %d\n", e->e);
 			}
-		} else {
-			for (i=0;i<NUM_DCHANS;i++) {
-				if (!pri->dchannels[i])
-					break;
-				/* Check for an event */
-				x = 0;
-				res = ioctl(pri->fds[i], ZT_GETEVENT, &x);
-				if (x) 
-					ast_log(LOG_NOTICE, "PRI got event: %d on %s D-channel of span %d\n", x, pri_order(i), pri->span);
-
-				/* Keep track of alarm state */	
-				if (x == ZT_EVENT_ALARM) {
-					pri->dchanavail[i] &= ~(DCHAN_NOTINALARM | DCHAN_UP);
-					pri_find_dchan(pri);
-				} else if (x == ZT_EVENT_NOALARM) {
-					pri->dchanavail[i] |= DCHAN_NOTINALARM;
-					pri_find_dchan(pri);
-				}
-				
-				if (option_debug)
-					ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
-			}
 		}	
 		ast_mutex_unlock(&pri->lock);
 	}




More information about the svn-commits mailing list