]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
fixed a bug which caused chan_misdn to try to allocate 2 times the same channel on...
authorChristian Richter <christian.richter@beronet.com>
Fri, 27 Oct 2006 09:24:01 +0000 (09:24 +0000)
committerChristian Richter <christian.richter@beronet.com>
Fri, 27 Oct 2006 09:24:01 +0000 (09:24 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@46350 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_misdn.c
channels/misdn/isdn_lib.c
channels/misdn/isdn_lib.h
channels/misdn/isdn_msg_parser.c

index 07d442e8d9fc736f7c280e9f27b1a64e2798d3fe..4f2fac44235d1b03211dc9a484ecfecb19fe5aa6 100644 (file)
@@ -3839,6 +3839,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                        ch->state=MISDN_CLEANING;
        }
        break;
+       case EVENT_BCHAN_ERROR:
        case EVENT_CLEANUP:
        {
                stop_bc_tones(ch);
index 93be0995692dbeea4c997e0e190b8f0093ab6549..f07951c57ab1df61f7a14dd2bb5684a319cc0143 100644 (file)
@@ -633,17 +633,12 @@ int clean_up_bc(struct misdn_bchannel *bc)
        
        cb_log(2, stack->port, "$$$ Cleaning up bc with stid :%x pid:%d\n", bc->b_stid, bc->pid);
        
-       manager_bchannel_deactivate(bc);
-
-
        manager_ec_disable(bc);
 
+       manager_bchannel_deactivate(bc);
 
        mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_TARGET|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
        
-       /*mISDN_clear_stack(stack->midev, bc->b_stid);*/
-
-       
        bc->b_stid = 0;
        bc_state_change(bc, BCHAN_CLEANED);
        
@@ -1014,6 +1009,7 @@ int setup_bc(struct misdn_bchannel *bc)
                mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
                
                bc_state_change(bc,BCHAN_ERROR);
+               cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data);
                return(-EINVAL);
        }
 
@@ -1024,6 +1020,7 @@ int setup_bc(struct misdn_bchannel *bc)
                mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
                
                bc_state_change(bc,BCHAN_ERROR);
+               cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data);
                return(-EINVAL);
        }
 
@@ -1036,6 +1033,8 @@ int setup_bc(struct misdn_bchannel *bc)
                mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
                
                bc_state_change(bc,BCHAN_ERROR);
+               cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data);
+               return (-EINVAL);
        }
 
        manager_bchannel_activate(bc);
@@ -1467,7 +1466,7 @@ int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_t *frm)
                case EVENT_SETUP_ACKNOWLEDGE:
 
                setup_bc(bc);
-               
+
                case EVENT_SETUP:
                        
                {
@@ -1511,21 +1510,6 @@ int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_t *frm)
        return 0;
 }
 
-int handle_new_process(struct misdn_stack *stack, iframe_t *frm)
-{
-  
-       struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1);
-       
-       
-       if (!bc) {
-               cb_log(0, stack->port, " --> !! lib: No free channel!\n");
-               return -1;
-       }
-  
-       cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",frm->dinfo);
-       bc->l3_id=frm->dinfo;
-       return 0;
-}
 
 int handle_cr ( struct misdn_stack *stack, iframe_t *frm)
 {
@@ -1534,9 +1518,15 @@ int handle_cr ( struct misdn_stack *stack, iframe_t *frm)
        switch (frm->prim) {
        case CC_NEW_CR|INDICATION:
                cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
-               if (handle_new_process(stack, frm) <0) {
+
+               struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1);
+               if (!bc) {
+                       cb_log(0, stack->port, " --> !! lib: No free channel!\n");
                        return -1;
                }
+  
+               cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",frm->dinfo);
+               bc->l3_id=frm->dinfo;
                return 1;
        case CC_NEW_CR|CONFIRM:
                return 1;
@@ -1787,12 +1777,10 @@ handle_event_nt(void *dat, void *arg)
       
                case CC_SETUP|INDICATION:
                {
-                       iframe_t frm; /* fake te frm to add callref to global callreflist */
-                       frm.dinfo = hh->dinfo;
-                       frm.addr=stack->upper_id;
-                       frm.prim = CC_NEW_CR|INDICATION;
-                       
-                       if (handle_cr(stack, &frm)< 0) {
+                       struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1);
+                       if (!bc) 
+                       ERR_NO_CHANNEL:
+                       {
                                msg_t *dmsg;
                                cb_log(4, stack->port, "Patch from MEIDANIS:Sending RELEASE_COMPLETE %x (No free Chan for you..)\n", hh->dinfo);
                                dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
@@ -1800,6 +1788,16 @@ handle_event_nt(void *dat, void *arg)
                                free_msg(msg);
                                return 0;
                        }
+  
+                       cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo);
+                       bc->l3_id=hh->dinfo;
+
+                       if (bc->channel<=0) {
+                               bc->channel=find_free_chan_in_stack(stack,0);
+
+                               if (bc->channel<=0)
+                                       goto ERR_NO_CHANNEL;
+                       }
                }
                break;
 
index dcd41c26fd37e6ed65cc16fb575de2a4fcb64172..0d8ce2d1b08f538c860a8335ee9640b7c644227c 100644 (file)
@@ -113,6 +113,7 @@ enum event_e {
        EVENT_TONE_GENERATE,
        EVENT_BCHAN_DATA,
        EVENT_BCHAN_ACTIVATED,
+       EVENT_BCHAN_ERROR,
        EVENT_CLEANUP,
        EVENT_PROCEEDING,
        EVENT_PROGRESS,
index 540098d23d43c3e0bfde50d4c10725e44a146ebb..136c9a62ddd8fbf720d518d872a42fa9dfb124e6 100644 (file)
@@ -1219,6 +1219,7 @@ char EVENT_PORT_ALARM_INFO[] = "ALARM";
 char EVENT_BCHAN_DATA_INFO[] = "BCHAN_DATA";
 char EVENT_BCHAN_ACTIVATED_INFO[] = "BCHAN_ACTIVATED";
 char EVENT_TONE_GENERATE_INFO[] = "TONE_GENERATE";
+char EVENT_BCHAN_ERROR_INFO[] = "BCHAN_ERROR";
 
 char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt)
 {
@@ -1234,6 +1235,7 @@ char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt)
        if (event == EVENT_BCHAN_ACTIVATED) return EVENT_BCHAN_ACTIVATED_INFO;
        if (event == EVENT_TONE_GENERATE) return EVENT_TONE_GENERATE_INFO;
        if (event == EVENT_PORT_ALARM) return EVENT_PORT_ALARM_INFO;
+       if (event == EVENT_BCHAN_ERROR) return EVENT_BCHAN_ERROR_INFO;
        
        return NULL;
 }