[asterisk-commits] trunk r17404 - in /trunk/channels: ./ misdn/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Apr 4 12:09:30 MST 2006


Author: crichter
Date: Tue Apr  4 14:09:26 2006
New Revision: 17404

URL: http://svn.digium.com/view/asterisk?rev=17404&view=rev
Log:
 fixed some essential segfaults happening under heavy load. Added a bit more error handling if we receive wrong data form mISDN (e.g. if we crashed before => handle_err() ). Added first steps to implement the parseing of the connected party number.

Modified:
    trunk/channels/chan_misdn.c
    trunk/channels/misdn/Makefile
    trunk/channels/misdn/isdn_lib.c
    trunk/channels/misdn/isdn_msg_parser.c

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=17404&r1=17403&r2=17404&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Tue Apr  4 14:09:26 2006
@@ -1218,6 +1218,9 @@
 		}
 		
 		ch->jb=misdn_jb_init(len, threshold);
+
+		if (!ch->jb ) 
+			bc->nojitter=1;
 	}
 }
 
@@ -1930,7 +1933,6 @@
 	
 	release_unlock;
 	
-	
 	{
 		const char *varcause=NULL;
 		bc->cause=ast->hangupcause?ast->hangupcause:16;
@@ -2012,6 +2014,7 @@
     
 	}
 	
+
 	chan_misdn_log(1, bc->port, "Channel: %s hanguped\n",ast->name);
 	
 	return 0;
@@ -2107,7 +2110,7 @@
 	}
 
 	if ( ! ch->bc->addr ) {
-		chan_misdn_log(4, ch->bc->port, "misdn_write: no addr for bc dropping:%d\n", frame->samples);
+		chan_misdn_log(8, ch->bc->port, "misdn_write: no addr for bc dropping:%d\n", frame->samples);
 		return 0;
 	}
 	
@@ -4227,7 +4230,19 @@
     jb->state_empty = 0;
     jb->bytes_wrote = 0;
     jb->samples = (char *)malloc(size*sizeof(char));
+
+    if (!jb->samples) {
+	    chan_misdn_log(-1,0,"No free Mem for jb->samples\n");
+	    return NULL;
+    }
+    
     jb->ok = (char *)malloc(size*sizeof(char));
+
+    if (!jb->ok) {
+	    chan_misdn_log(-1,0,"No free Mem for jb->ok\n");
+	    return NULL;
+    }
+
     for(i=0; i<size; i++)
  	jb->ok[i]=0;
 
@@ -4240,7 +4255,6 @@
 void misdn_jb_destroy(struct misdn_jb *jb)
 {
 	ast_mutex_destroy(&jb->mutexjb);
-	
 	
 	free(jb->samples);
 	free(jb);
@@ -4374,7 +4388,8 @@
 {
 	if (! ((0 <= port) && (port <= max_ports))) {
 		ast_log(LOG_WARNING, "cb_log called with out-of-range port number! (%d)\n", port);
-		port=-1;
+		port=0;
+		level=-1;
 	}
 		
 	va_list ap;

Modified: trunk/channels/misdn/Makefile
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/Makefile?rev=17404&r1=17403&r2=17404&view=diff
==============================================================================
--- trunk/channels/misdn/Makefile (original)
+++ trunk/channels/misdn/Makefile Tue Apr  4 14:09:26 2006
@@ -5,7 +5,7 @@
 #
 
 # Verify those options with main Makefile
-CFLAGS		= -pipe -c -Wall
+CFLAGS		= -pipe -c -Wall -ggdb
 ifeq ($(shell uname -m),x86_64)
 CFLAGS	       += -fPIC
 endif

Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?rev=17404&r1=17403&r2=17404&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Tue Apr  4 14:09:26 2006
@@ -880,6 +880,11 @@
 	
 
 	struct misdn_stack *stack=get_stack_by_bc(bc);
+
+	if (!stack) {
+		cb_log(-1, bc->port, "setup_bc: NO STACK FOUND!!\n");
+		return -1;
+	}
 	
 	int midev=stack->midev;
 	int channel=bc->channel-1-(bc->channel>16);
@@ -2790,7 +2795,12 @@
 	if (!bc) goto ERR; 
 	
 	struct misdn_stack *stack=get_stack_by_bc(bc);
-
+	
+	if (!stack) {
+		cb_log(-1,bc->port,"SENDEVENT: no Stack for event:%s oad:%s dad:%s \n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad);
+		return -1;
+	}
+	
 	cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id);
 
 	if ( stack->nt && !stack->l1link) {
@@ -2938,6 +2948,43 @@
 }
 
 
+int handle_err(msg_t *msg)
+{
+	iframe_t *frm = (iframe_t*) msg->data;
+	unsigned char buff[32];
+	
+	switch (frm->prim) {
+		case DL_DATA|INDICATION:
+			{
+			struct misdn_stack *stack=find_stack_by_port( (frm->addr&MASTER_ID_MASK) >> 8);
+			if (!stack) {
+				cb_log(-1,0,"BCHAN DATA without having a Chan Object (addr:%x) probably we died before closing..\n",frm->addr);
+				return 0;
+			}
+			cb_log(-1,stack->port,"BCHAN DATA without having a Chan Object (addr:%x) probably we died before closing..\n",frm->addr);
+
+			if (stack->l1link)
+				misdn_lib_get_l1_down(stack);
+#if 0
+			iframe_t dact;
+			dact.prim = DL_RELEASE | REQUEST;
+			dact.addr = frm->addr | FLG_MSG_DOWN;
+			dact.dinfo = 0;
+			dact.len = 0;
+	
+			mISDN_write(glob_mgr->midev, &dact, mISDN_HEADER_LEN+dact.len, TIMEOUT_1SEC);
+
+			mISDN_write_frame(glob_mgr->midev, buff, frm->addr|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
+#endif
+			free_msg(msg);
+			return 1;
+			}
+	}
+
+	return 0;
+}
+
+
 int manager_isdn_handler(iframe_t *frm ,msg_t *msg)
 {  
 
@@ -2971,6 +3018,9 @@
 	if (handle_frm(msg)) 
 		return 0 ;
 
+	if (handle_err(msg)) 
+		return 0 ;
+	
 	cb_log(-1, 0, "Unhandled Message: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo);		
    
 	free_msg(msg);
@@ -3322,7 +3372,8 @@
 	struct misdn_stack *stack=get_stack_by_bc(bc);
 
 	if (!stack) {
-		cb_log(-1, stack->port, "bchannel_activate: Stack not found !");
+		cb_log(-1, bc->port, "bchannel_activate: Stack not found !");
+		return ;
 	}
 	
 	if (!msg) {
@@ -3370,7 +3421,6 @@
 
 void manager_bchannel_deactivate(struct misdn_bchannel * bc)
 {
-	iframe_t dact;
 
 	struct misdn_stack *stack=get_stack_by_bc(bc);
 
@@ -3391,6 +3441,7 @@
 	
 	bc->generate_tone=0;
 	
+	iframe_t dact;
 	dact.prim = DL_RELEASE | REQUEST;
 	dact.addr = bc->addr | FLG_MSG_DOWN;
 	dact.dinfo = 0;

Modified: trunk/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_msg_parser.c?rev=17404&r1=17403&r2=17404&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_msg_parser.c (original)
+++ trunk/channels/misdn/isdn_msg_parser.c Tue Apr  4 14:09:26 2006
@@ -333,10 +333,17 @@
 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
 	CONNECT_t *connect=(CONNECT_t*)((unsigned long)(msg->data+HEADER_LEN));
   
+	int type,plan,pres,screen;
+	char connected_pn[32];
+	
 	bc->ces = connect->ces;
 	bc->ces = connect->ces;
 
 	dec_ie_progress(connect->PROGRESS, (Q931_info_t *)connect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
+
+	dec_ie_connected_pn(connect->CONNECT_PN,(Q931_info_t *)connect, &type, &plan, &pres, &screen, connected_pn, 31, nt, bc);
+
+	cb_log(1,bc->port,"CONNETED PN: %s cpn_dialplan:%d\n", connected_pn, type);
 	
 #if DEBUG 
 	printf("Parsing CONNECT Msg\n"); 



More information about the asterisk-commits mailing list