find_free_chan_in_stack: cleanup buggy usage

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46906 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Nadi Sarrar 19 years ago
parent 5a87a3bbb2
commit a2cb7d974e

@ -826,14 +826,13 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
int l3_id; int l3_id;
int i; int i;
struct misdn_stack *stack=get_stack_by_bc(bc); struct misdn_stack *stack=get_stack_by_bc(bc);
int free_chan;
if (stack->nt) { if (stack->nt) {
free_chan = find_free_chan_in_stack(stack, bc, bc->channel_preselected?bc->channel:0); if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0))
if (!free_chan) return -1; return -1;
/*bc->channel=free_chan;*/ /*bc->channel=free_chan;*/
cb_log(4,stack->port, " --> found channel: %d\n",free_chan); cb_log(4,stack->port, " --> found channel: %d\n", bc->channel);
for (i=0; i <= MAXPROCS; i++) for (i=0; i <= MAXPROCS; i++)
if (stack->procids[i]==0) break; if (stack->procids[i]==0) break;
@ -859,10 +858,10 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
} else { } else {
if (stack->ptp || bc->te_choose_channel) { if (stack->ptp || bc->te_choose_channel) {
/* we know exactly which channels are in use */ /* we know exactly which channels are in use */
free_chan = find_free_chan_in_stack(stack, bc, bc->channel_preselected?bc->channel:0); if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0))
if (!free_chan) return -1; return -1;
/*bc->channel=free_chan;*/ /*bc->channel=free_chan;*/
cb_log(2,stack->port, " --> found channel: %d\n",free_chan); cb_log(2,stack->port, " --> found channel: %d\n", bc->channel);
} else { } else {
/* other phones could have made a call also on this port (ptmp) */ /* other phones could have made a call also on this port (ptmp) */
bc->channel=0xff; bc->channel=0xff;
@ -1498,8 +1497,7 @@ static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_
{ {
if (bc->channel == 0xff) { if (bc->channel == 0xff) {
bc->channel=find_free_chan_in_stack(stack, bc, 0); if (!find_free_chan_in_stack(stack, bc, 0)) {
if (!bc->channel) {
cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n"); cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
break; break;
} }
@ -1801,9 +1799,7 @@ handle_event_nt(void *dat, void *arg)
bc->l3_id=hh->dinfo; bc->l3_id=hh->dinfo;
if (bc->channel<=0) { if (bc->channel<=0) {
bc->channel=find_free_chan_in_stack(stack,0,0); if (!find_free_chan_in_stack(stack, bc, 0))
if (bc->channel<=0)
goto ERR_NO_CHANNEL; goto ERR_NO_CHANNEL;
} }
} }
@ -2042,8 +2038,7 @@ handle_event_nt(void *dat, void *arg)
} else { } else {
bc->channel = find_free_chan_in_stack(stack, bc, 0); if (!find_free_chan_in_stack(stack, bc, 0)) {
if (!bc->channel) {
cb_log(0, stack->port, " No free channel at the moment\n"); cb_log(0, stack->port, " No free channel at the moment\n");
msg_t *dmsg; msg_t *dmsg;
@ -3232,8 +3227,7 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
if (stack->nt) { if (stack->nt) {
if (bc->channel <=0 ) { /* else we have the channel already */ if (bc->channel <=0 ) { /* else we have the channel already */
bc->channel = find_free_chan_in_stack(stack, bc, 0); if (!find_free_chan_in_stack(stack, bc, 0)) {
if (!bc->channel) {
cb_log(0, stack->port, " No free channel at the moment\n"); cb_log(0, stack->port, " No free channel at the moment\n");
err=-ENOCHAN; err=-ENOCHAN;

@ -302,8 +302,8 @@ static const struct misdn_cfg_spec port_spec[] = {
"\t yes (= 4 seconds)\n" "\t yes (= 4 seconds)\n"
"\t no (= 0 seconds = disabled)" }, "\t no (= 0 seconds = disabled)" },
{ "nttimeout", MISDN_CFG_NTTIMEOUT, MISDN_CTYPE_BOOL, "no", NONE , { "nttimeout", MISDN_CFG_NTTIMEOUT, MISDN_CTYPE_BOOL, "no", NONE ,
"Set this to yes if you want calls disconnected in overlap mode" "Set this to yes if you want calls disconnected in overlap mode\n"
"when a timeout happens.\n"}, "\twhen a timeout happens." },
{ "msns", MISDN_CFG_MSNS, MISDN_CTYPE_MSNLIST, NO_DEFAULT, NONE, { "msns", MISDN_CFG_MSNS, MISDN_CTYPE_MSNLIST, NO_DEFAULT, NONE,
"MSN's for TE ports, listen on those numbers on the above ports, and\n" "MSN's for TE ports, listen on those numbers on the above ports, and\n"
"\tindicate the incoming calls to Asterisk.\n" "\tindicate the incoming calls to Asterisk.\n"

Loading…
Cancel
Save