Merged revisions 336167 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10 ................ r336167 | irroot | 2011-09-16 12:12:03 +0200 (Fri, 16 Sep 2011) | 22 lines Merged revisions 336166 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r336166 | irroot | 2011-09-16 12:09:17 +0200 (Fri, 16 Sep 2011) | 16 lines The round robin routing routine in chan_misdn.c is broken. it rotates between ports but never checks the channels in the ports. i have extensivly tested it and verified it works on 1 upto 4 ports. before the patch only 1 out of each port was used now all are used as expected. (closes issue ASTERISK-18413) Reported by: irroot Tested by: irroot Reviewed by: irroot Review: https://reviewboard.asterisk.org/r/1410/ ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@336168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
6f7ff1074b
commit
b5a641d1fe
|
@ -7886,64 +7886,63 @@ static struct ast_channel *misdn_request(const char *type, struct ast_format_cap
|
|||
}
|
||||
|
||||
if (rr) {
|
||||
int robin_channel = rr->channel;
|
||||
int port_start;
|
||||
int next_chan = 1;
|
||||
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;
|
||||
}
|
||||
|
||||
if (port >= port_start) {
|
||||
next_chan = 1;
|
||||
}
|
||||
|
||||
if (port <= port_start && next_chan) {
|
||||
int maxbchans = misdn_lib_get_maxchans(port);
|
||||
|
||||
if (++robin_channel >= maxbchans) {
|
||||
robin_channel = 1;
|
||||
}
|
||||
next_chan = 0;
|
||||
}
|
||||
|
||||
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, robin_channel, 0, 0);
|
||||
if (newbc) {
|
||||
chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
|
||||
if (port_up) {
|
||||
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;
|
||||
}
|
||||
} while (!newbc && robin_channel != rr->channel);
|
||||
|
||||
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 && (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)) {
|
||||
|
|
Loading…
Reference in New Issue