[asterisk-commits] branch crichter/0.3.0 r17371 - in
/team/crichter/0.3.0/channels: ./ misdn/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Apr 4 11:46:37 MST 2006
Author: crichter
Date: Tue Apr 4 13:46:32 2006
New Revision: 17371
URL: http://svn.digium.com/view/asterisk?rev=17371&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:
team/crichter/0.3.0/channels/chan_misdn.c
team/crichter/0.3.0/channels/misdn/Makefile
team/crichter/0.3.0/channels/misdn/isdn_lib.c
team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c
Modified: team/crichter/0.3.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/chan_misdn.c?rev=17371&r1=17370&r2=17371&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/chan_misdn.c (original)
+++ team/crichter/0.3.0/channels/chan_misdn.c Tue Apr 4 13:46:32 2006
@@ -1217,6 +1217,9 @@
}
ch->jb=misdn_jb_init(len, threshold);
+
+ if (!ch->jb )
+ bc->nojitter=1;
}
}
@@ -1927,7 +1930,6 @@
release_unlock;
-
{
const char *varcause=NULL;
bc->cause=ast->hangupcause?ast->hangupcause:16;
@@ -2009,6 +2011,7 @@
}
+
chan_misdn_log(1, bc->port, "Channel: %s hanguped\n",ast->name);
return 0;
@@ -2104,7 +2107,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;
}
@@ -4223,7 +4226,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;
@@ -4236,7 +4251,6 @@
void misdn_jb_destroy(struct misdn_jb *jb)
{
ast_mutex_destroy(&jb->mutexjb);
-
free(jb->samples);
free(jb);
@@ -4370,7 +4384,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: team/crichter/0.3.0/channels/misdn/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/Makefile?rev=17371&r1=17370&r2=17371&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/Makefile (original)
+++ team/crichter/0.3.0/channels/misdn/Makefile Tue Apr 4 13:46:32 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: team/crichter/0.3.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_lib.c?rev=17371&r1=17370&r2=17371&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_lib.c Tue Apr 4 13:46:32 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);
@@ -2791,7 +2796,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) {
@@ -2939,6 +2949,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)
{
@@ -2972,6 +3019,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);
@@ -3323,7 +3373,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) {
@@ -3371,7 +3422,6 @@
void manager_bchannel_deactivate(struct misdn_bchannel * bc)
{
- iframe_t dact;
struct misdn_stack *stack=get_stack_by_bc(bc);
@@ -3392,6 +3442,7 @@
bc->generate_tone=0;
+ iframe_t dact;
dact.prim = DL_RELEASE | REQUEST;
dact.addr = bc->addr | FLG_MSG_DOWN;
dact.dinfo = 0;
Modified: team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c?rev=17371&r1=17370&r2=17371&view=diff
==============================================================================
--- team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c (original)
+++ team/crichter/0.3.0/channels/misdn/isdn_msg_parser.c Tue Apr 4 13:46:32 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