[asterisk-commits] rmudgett: trunk r284782 - in /trunk: ./ channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 2 16:08:45 CDT 2010


Author: rmudgett
Date: Thu Sep  2 16:08:41 2010
New Revision: 284782

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=284782
Log:
Merged revisions 284779-284780 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r284779 | rmudgett | 2010-09-02 15:59:12 -0500 (Thu, 02 Sep 2010) | 8 lines
  
  Made output libpri event names if pri debugging is enabled when sig_pri processes them.
  
  * Simplified CLI "pri debug xx span xx" command code and removed redundant
  debugging enabled messages.
  
  * Made CLI "pri debug xx span xx" command only close the debugging log
  file if it was opened.
........
  r284780 | rmudgett | 2010-09-02 16:02:54 -0500 (Thu, 02 Sep 2010) | 2 lines
  
  Simplified pri_dchannel() poll timeout duration code.
........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_dahdi.c
    trunk/channels/sig_pri.c
    trunk/channels/sig_pri.h

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=284782&r1=284781&r2=284782
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Thu Sep  2 16:08:41 2010
@@ -13734,25 +13734,36 @@
 		ast_cli(a->fd, "No PRI running on span %d\n", span);
 		return CLI_SUCCESS;
 	}
+
+	/* Set debug level in libpri */
 	for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) {
-		if (pris[span-1].pri.dchans[x]) {
-			if (level == 1) {
-				pri_set_debug(pris[span-1].pri.dchans[x], SIG_PRI_DEBUG_NORMAL);
-				ast_cli(a->fd, "Enabled debugging on span %d\n", span);
-			} else if (level == 0) {
-				pri_set_debug(pris[span-1].pri.dchans[x], 0);
-				/* close the file if it's set */
-				ast_mutex_lock(&pridebugfdlock);
-				close(pridebugfd);
-				pridebugfd = -1;
-				ast_cli(a->fd, "PRI debug output to file disabled\n");
-				ast_mutex_unlock(&pridebugfdlock);
-			} else {
-				pri_set_debug(pris[span-1].pri.dchans[x], SIG_PRI_DEBUG_INTENSE);
-				ast_cli(a->fd, "Enabled debugging on span %d\n", span);
-			}
-		}
-	}
+		if (pris[span - 1].pri.dchans[x]) {
+			switch (level) {
+			case 0:
+				pri_set_debug(pris[span - 1].pri.dchans[x], 0);
+				break;
+			case 1:
+				pri_set_debug(pris[span - 1].pri.dchans[x], SIG_PRI_DEBUG_NORMAL);
+				break;
+			default:
+				pri_set_debug(pris[span - 1].pri.dchans[x], SIG_PRI_DEBUG_INTENSE);
+				break;
+			}
+		}
+	}
+	if (level == 0) {
+		/* Close the debugging file if it's set */
+		ast_mutex_lock(&pridebugfdlock);
+		if (0 <= pridebugfd) {
+			close(pridebugfd);
+			pridebugfd = -1;
+			ast_cli(a->fd, "Disabled PRI debug output to file '%s'\n",
+				pridebugfilename);
+		}
+		ast_mutex_unlock(&pridebugfdlock);
+	}
+	pris[span - 1].pri.debug = (level) ? 1 : 0;
+	ast_cli(a->fd, "%s debugging on span %d\n", (level) ? "Enabled" : "Disabled", span);
 	return CLI_SUCCESS;
 }
 #endif	/* defined(HAVE_PRI) */
@@ -13969,7 +13980,7 @@
 	int x;
 	int span;
 	int count=0;
-	int debug=0;
+	int debug;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -13985,7 +13996,6 @@
 	for (span = 0; span < NUM_SPANS; span++) {
 		if (pris[span].pri.pri) {
 			for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) {
-				debug = 0;
 				if (pris[span].pri.dchans[x]) {
 					debug = pri_get_debug(pris[span].pri.dchans[x]);
 					ast_cli(a->fd, "Span %d: Debug: %s\tIntense: %s\n", span+1, (debug&PRI_DEBUG_Q931_STATE)? "Yes" : "No" ,(debug&PRI_DEBUG_Q921_RAW)? "Yes" : "No" );
@@ -14001,7 +14011,7 @@
 	ast_mutex_unlock(&pridebugfdlock);
 
 	if (!count)
-		ast_cli(a->fd, "No debug set or no PRI running\n");
+		ast_cli(a->fd, "No PRI running\n");
 	return CLI_SUCCESS;
 }
 #endif	/* defined(HAVE_PRI) */

Modified: trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.c?view=diff&rev=284782&r1=284781&r2=284782
==============================================================================
--- trunk/channels/sig_pri.c (original)
+++ trunk/channels/sig_pri.c Thu Sep  2 16:08:41 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);
@@ -4243,8 +4243,10 @@
 			ast_log(LOG_WARNING, "pri_event returned error %d (%s)\n", errno, strerror(errno));
 
 		if (e) {
-			if (pri->debug)
-				pri_dump_event(pri->dchans[which], e);
+			if (pri->debug) {
+				ast_verbose("Span: %d Processing event: %s\n",
+					pri->span, pri_event2str(e->e));
+			}
 
 			if (e->e != PRI_EVENT_DCHAN_DOWN) {
 				if (!(pri->dchanavail[which] & DCHAN_UP)) {

Modified: trunk/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.h?view=diff&rev=284782&r1=284781&r2=284782
==============================================================================
--- trunk/channels/sig_pri.h (original)
+++ trunk/channels/sig_pri.h Thu Sep  2 16:08:41 2010
@@ -389,7 +389,7 @@
 	int num_call_waiting_calls;
 #endif	/* defined(HAVE_PRI_CALL_WAITING) */
 	int dchanavail[SIG_PRI_NUM_DCHANS];		/*!< Whether each channel is available */
-	int debug;								/*!< set to true if to dump PRI event info (tested but never set) */
+	int debug;								/*!< set to true if to dump PRI event info */
 	int span;								/*!< span number put into user output messages */
 	int resetting;							/*!< true if span is being reset/restarted */
 	int resetpos;							/*!< current position during a reset (-1 if not started) */




More information about the asterisk-commits mailing list