[svn-commits] rmudgett: branch 1.8 r284780 - /branches/1.8/channels/sig_pri.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Sep 2 16:02:58 CDT 2010


Author: rmudgett
Date: Thu Sep  2 16:02:54 2010
New Revision: 284780

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=284780
Log:
Simplified pri_dchannel() poll timeout duration code.

Modified:
    branches/1.8/channels/sig_pri.c

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=284780&r1=284779&r2=284780
==============================================================================
--- branches/1.8/channels/sig_pri.c (original)
+++ branches/1.8/channels/sig_pri.c Thu Sep  2 16:02:54 2010
@@ -4176,36 +4176,36 @@
 			}
 		}
 		/* Start with reasonable max */
-		lowest = ast_tv(60, 0);
+		if (doidling || pri->resetting) {
+			/*
+			 * Make sure we stop at least once per second if we're
+			 * monitoring idle channels
+			 */
+			lowest = ast_tv(1, 0);
+		} else {
+			/* Don't poll for more than 60 seconds */
+			lowest = ast_tv(60, 0);
+		}
 		for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) {
-			/* Find lowest available d-channel */
-			if (!pri->dchans[i])
+			if (!pri->dchans[i]) {
+				/* We scanned all D channels on this span. */
 				break;
-			if ((next = pri_schedule_next(pri->dchans[i]))) {
+			}
+			next = pri_schedule_next(pri->dchans[i]);
+			if (next) {
 				/* We need relative time here */
 				tv = ast_tvsub(*next, ast_tvnow());
 				if (tv.tv_sec < 0) {
-					tv = ast_tv(0,0);
-				}
-				if (doidling || pri->resetting) {
-					if (tv.tv_sec > 1) {
-						tv = ast_tv(1, 0);
-					}
-				} else {
-					if (tv.tv_sec > 60) {
-						tv = ast_tv(60, 0);
-					}
-				}
-			} else if (doidling || pri->resetting) {
-				/* Make sure we stop at least once per second if we're
-				   monitoring idle channels */
-				tv = ast_tv(1,0);
-			} else {
-				/* Don't poll for more than 60 seconds */
-				tv = ast_tv(60, 0);
-			}
-			if (!i || ast_tvcmp(tv, lowest) < 0) {
-				lowest = tv;
+					/*
+					 * A timer has already expired.
+					 * By definition zero time is the lowest so we can quit early.
+					 */
+					lowest = ast_tv(0, 0);
+					break;
+				}
+				if (ast_tvcmp(tv, lowest) < 0) {
+					lowest = tv;
+				}
 			}
 		}
 		ast_mutex_unlock(&pri->lock);




More information about the svn-commits mailing list