[asterisk-commits] irroot: branch irroot/distrotech-customers-10 r334419 - in /team/irroot/distr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Sep 3 07:20:28 CDT 2011


Author: irroot
Date: Sat Sep  3 07:20:17 2011
New Revision: 334419

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334419
Log:

Redo the entire round robin routing routine for misdn channels.

round robin can now be used as expected on single ports.


Modified:
    team/irroot/distrotech-customers-10/   (props changed)
    team/irroot/distrotech-customers-10/channels/chan_misdn.c

Propchange: team/irroot/distrotech-customers-10/
------------------------------------------------------------------------------
    automerge = *

Modified: team/irroot/distrotech-customers-10/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/channels/chan_misdn.c?view=diff&rev=334419&r1=334418&r2=334419
==============================================================================
--- team/irroot/distrotech-customers-10/channels/chan_misdn.c (original)
+++ team/irroot/distrotech-customers-10/channels/chan_misdn.c Sat Sep  3 07:20:17 2011
@@ -7874,46 +7874,62 @@
 
 		if (rr) {
 			int port_start;
-
+			int bchan_start;
+			int port_up;
+			int check;
+			int maxbchans;
+
+			if (!rr->port) {
+				rr->port = misdn_cfg_get_next_port_spin(0);
+			}
+
+			if (!rr->channel) {
+				rr->channel = 1;
+			}
+
+			bchan_start = rr->channel;
+			port_start = rr->port;
 			do {
-				port_start = 0;
-				for (port = misdn_cfg_get_next_port_spin(rr->port); port > 0 && port != port_start;
-					 port = misdn_cfg_get_next_port_spin(port)) {
-
-					if (!port_start) {
-						port_start = port;
-					}
-
-					misdn_cfg_get(port, MISDN_CFG_GROUPNAME, cfg_group, sizeof(cfg_group));
-
-					if (!strcasecmp(cfg_group, group)) {
-						int port_up;
-						int check;
-
-						misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(check));
-						port_up = misdn_lib_port_up(port, check);
-
-						if (check && !port_up) {
-							chan_misdn_log(1, port, "L1 is not Up on this Port\n");
-						}
-
-						if (check && port_up < 0) {
-							ast_log(LOG_WARNING, "This port (%d) is blocked\n", port);
-						}
-
-						if (port_up > 0) {
-							newbc = misdn_lib_get_free_bc(port, 0, 0, dec);
-							if (newbc) {
-								chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
-								chan_misdn_log(4, port, "portup:%d\n",  port_up);
-								rr->port = newbc->port;
-								rr->channel = newbc->channel;
-								break;
-							}
+				misdn_cfg_get(rr->port, MISDN_CFG_GROUPNAME, cfg_group, sizeof(cfg_group));
+				if (strcasecmp(cfg_group, group)) {
+					rr->port = misdn_cfg_get_next_port_spin(rr->port);
+					rr->channel = 1;
+					continue;
+				}
+
+				misdn_cfg_get(rr->port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(check));
+				port_up = misdn_lib_port_up(rr->port, check);
+
+				if (!port_up) {
+					chan_misdn_log(1, rr->port, "L1 is not Up on this Port\n");
+					rr->port = misdn_cfg_get_next_port_spin(rr->port);
+					rr->channel = 1;
+				} else if (port_up < 0) {
+					ast_log(LOG_WARNING, "This port (%d) is blocked\n", rr->port);
+					rr->port = misdn_cfg_get_next_port_spin(rr->port);
+					rr->channel = 1;
+				} else {
+					chan_misdn_log(4, rr->port, "portup\n");
+					maxbchans = misdn_lib_get_maxchans(rr->port);
+
+					for (;rr->channel <= maxbchans;rr->channel++) {
+						chan_misdn_log(4, rr->port, "Checking channel %d\n",  rr->channel);
+
+						if ((newbc = misdn_lib_get_free_bc(rr->port, rr->channel, 0, 0))) {
+							chan_misdn_log(4, rr->port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
+							rr->channel++;
+							break;
 						}
 					}
+					if (!newbc || (rr->channel > maxbchans)) {
+						rr->port = misdn_cfg_get_next_port_spin(rr->port);
+						rr->channel = 1;
+					}
+
 				}
-			} while (!newbc);
+			} while (!newbc && (rr->port > 0) &&
+				 ((rr->port != port_start) || ((rr->port == port_start) && (rr->channel < bchan_start))));
+
 		} else {
 			for (port = misdn_cfg_get_next_port(0); port > 0;
 				port = misdn_cfg_get_next_port(port)) {




More information about the asterisk-commits mailing list