]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
mISDN Round Robin break when no channel is available
authorGregory Nietsky <gregory@distrotech.co.za>
Sat, 12 Nov 2011 16:05:45 +0000 (16:05 +0000)
committerGregory Nietsky <gregory@distrotech.co.za>
Sat, 12 Nov 2011 16:05:45 +0000 (16:05 +0000)
Prevent channels been parsed repetitively.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@344965 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_misdn.c

index 6c6373cdadb128accab0b1795e67cac6566ef76e..46870a50b944375c9a64f3e3819f26d05fdeba6d 100644 (file)
@@ -7889,6 +7889,7 @@ static struct ast_channel *misdn_request(const char *type, format_t format, cons
                        int port_up;
                        int check;
                        int maxbchans;
+                       int wraped = 0;
 
                        if (!rr->port) {
                                rr->port = misdn_cfg_get_next_port_spin(0);
@@ -7903,6 +7904,7 @@ static struct ast_channel *misdn_request(const char *type, format_t format, cons
                        do {
                                misdn_cfg_get(rr->port, MISDN_CFG_GROUPNAME, cfg_group, sizeof(cfg_group));
                                if (strcasecmp(cfg_group, group)) {
+                                       wraped = 1;
                                        rr->port = misdn_cfg_get_next_port_spin(rr->port);
                                        rr->channel = 1;
                                        continue;
@@ -7924,6 +7926,11 @@ static struct ast_channel *misdn_request(const char *type, format_t format, cons
                                        maxbchans = misdn_lib_get_maxchans(rr->port);
 
                                        for (;rr->channel <= maxbchans;rr->channel++) {
+                                               /* ive come full circle and can stop now */
+                                               if (wraped && (rr->port == port_start) && (rr->channel == bchan_start)) {
+                                                       break;
+                                               }
+
                                                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))) {
@@ -7932,15 +7939,16 @@ static struct ast_channel *misdn_request(const char *type, format_t format, cons
                                                        break;
                                                }
                                        }
-                                       if (!newbc || (rr->channel > maxbchans)) {
+                                       if (wraped && (rr->port == port_start) && (rr->channel <= bchan_start)) {
+                                               break;
+                                       } else if (!newbc || (rr->channel == maxbchans)) {
                                                rr->port = misdn_cfg_get_next_port_spin(rr->port);
                                                rr->channel = 1;
                                        }
 
                                }
-                       } while (!newbc && (rr->port > 0) &&
-                                ((rr->port != port_start) || ((rr->port == port_start) && (rr->channel < bchan_start))));
-
+                               wraped = 1;
+                       } while (!newbc && (rr->port > 0));
                } else {
                        for (port = misdn_cfg_get_next_port(0); port > 0;
                                port = misdn_cfg_get_next_port(port)) {