[asterisk-commits] crichter: branch 1.4 r62912 - in /branches/1.4:
./ channels/ channels/misdn/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu May 3 07:36:32 MST 2007
Author: crichter
Date: Thu May 3 09:36:32 2007
New Revision: 62912
URL: http://svn.digium.com/view/asterisk?view=rev&rev=62912
Log:
Merged revisions 61357,61770,62885 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r61357 | crichter | 2007-04-11 14:05:57 +0200 (Mi, 11 Apr 2007) | 1 line
some fixes for PMP Hold/Retrieve, it should work now, when briding=no
........
r61770 | crichter | 2007-04-24 15:50:05 +0200 (Di, 24 Apr 2007) | 1 line
added lock for sending messages to avoid double sending. shuffled some empty_chans after the cb_event calls, this avoids that a release_complete from a quite different call releases a fresh created setup by accident.
........
r62885 | crichter | 2007-05-03 15:59:00 +0200 (Do, 03 Mai 2007) | 1 line
fixed the problem that misdn_write did not return -1 when called with 0 samples in a frame this resultet in a deadlock in some circumstances, when the call ended because of a busy extension. added encoding of keypad.
........
Modified:
branches/1.4/ (props changed)
branches/1.4/channels/chan_misdn.c
branches/1.4/channels/misdn/ie.c
branches/1.4/channels/misdn/isdn_lib.c
branches/1.4/channels/misdn/isdn_lib.h
branches/1.4/channels/misdn/isdn_lib_intern.h
branches/1.4/channels/misdn/isdn_msg_parser.c
Propchange: branches/1.4/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.
Modified: branches/1.4/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_misdn.c?view=diff&rev=62912&r1=62911&r2=62912
==============================================================================
--- branches/1.4/channels/chan_misdn.c (original)
+++ branches/1.4/channels/chan_misdn.c Thu May 3 09:36:32 2007
@@ -1135,8 +1135,8 @@
print_bc_info(fd, help, bc);
} else {
if (help->state == MISDN_HOLDED) {
- chan_misdn_log(2, 0, "ITS A HOLDED BC:\n");
- chan_misdn_log(2,0," --> l3_id: %x\n"
+ ast_cli(fd, "ITS A HOLDED BC:\n");
+ ast_cli(fd, " --> l3_id: %x\n"
" --> dad:%s oad:%s\n"
" --> hold_port: %d\n"
" --> hold_channel: %d\n"
@@ -2628,7 +2628,8 @@
chan_misdn_log(1,0,"misdn_read called without ast->pvt\n");
return NULL;
}
- if (!tmp->bc) {
+
+ if (!tmp->bc && !(tmp->state==MISDN_HOLDED)) {
chan_misdn_log(1,0,"misdn_read called without bc\n");
return NULL;
}
@@ -4634,7 +4635,11 @@
/***************************/
case EVENT_RETRIEVE:
{
- ch=find_holded_l3(cl_te, bc->l3_id,1);
+ if (!ch) {
+ chan_misdn_log(4, bc->port, " --> no CH, searching in holded");
+ ch=find_holded_l3(cl_te, bc->l3_id,1);
+ }
+
if (!ch) {
ast_log(LOG_WARNING, "Found no Holded channel, cannot Retrieve\n");
misdn_lib_send_event(bc, EVENT_RETRIEVE_REJECT);
Modified: branches/1.4/channels/misdn/ie.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/misdn/ie.c?view=diff&rev=62912&r1=62911&r2=62912
==============================================================================
--- branches/1.4/channels/misdn/ie.c (original)
+++ branches/1.4/channels/misdn/ie.c Thu May 3 09:36:32 2007
@@ -938,7 +938,7 @@
#endif
/* IE_KEYPAD */
-#if 0
+#if 1
static void enc_ie_keypad(unsigned char **ntmode, msg_t *msg, char *keypad, int nt, struct misdn_bchannel *bc)
{
unsigned char *p;
Modified: branches/1.4/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/misdn/isdn_lib.c?view=diff&rev=62912&r1=62911&r2=62912
==============================================================================
--- branches/1.4/channels/misdn/isdn_lib.c (original)
+++ branches/1.4/channels/misdn/isdn_lib.c Thu May 3 09:36:32 2007
@@ -1101,6 +1101,10 @@
cb_log(8, port, "Init.BC %d.\n",bidx);
memset(bc, 0,sizeof(struct misdn_bchannel));
+
+ bc->send_lock=malloc(sizeof(struct send_lock));
+
+ pthread_mutex_init(&bc->send_lock->lock, NULL);
if (msn) {
int l = sizeof(bc->msn);
@@ -1206,6 +1210,7 @@
stack->nt=1;
break;
+#ifndef MISDN_1_2
case ISDN_PID_L0_TE_U:
break;
case ISDN_PID_L0_NT_U:
@@ -1214,6 +1219,7 @@
break;
case ISDN_PID_L0_NT_UP2:
break;
+#endif
case ISDN_PID_L0_TE_E1:
cb_log(8, port, "TE S2M Stack\n");
stack->nt=0;
@@ -1545,14 +1551,6 @@
case EVENT_RELEASE_COMPLETE:
case EVENT_RELEASE:
- if (bc->channel>0)
- empty_chan_in_stack(stack,bc->channel);
- int tmpcause=bc->cause;
- int tmp_out_cause=bc->out_cause;
- empty_bc(bc);
- bc->cause=tmpcause;
- bc->out_cause=tmp_out_cause;
- clean_up_bc(bc);
break;
default:
break;
@@ -1607,17 +1605,18 @@
cb_log(4, stack->port, " --> lib: CLEANING UP l3id: %x\n",frm->dinfo);
if (bc->channel>0)
empty_chan_in_stack(stack,bc->channel);
- empty_bc(bc);
- clean_up_bc(bc);
-
- dump_chan_list(stack);
/*bc->pid = 0;*/
bc->need_disconnect=0;
bc->need_release=0;
bc->need_release_complete=0;
-
+
cb_event(EVENT_CLEANUP, bc, glob_mgr->user_data);
+
+ empty_bc(bc);
+ clean_up_bc(bc);
+ dump_chan_list(stack);
+
if (bc->stack_holder) {
cb_log(4,stack->port, "REMOVEING Holder\n");
stack_holder_remove( stack, bc);
@@ -1821,7 +1820,7 @@
return 0;
}
- cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo);
+ cb_log(4, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo);
bc->l3_id=hh->dinfo;
}
break;
@@ -2657,6 +2656,18 @@
}
}
+ if (event == EVENT_RELEASE_COMPLETE) {
+ /* release bchannel only after we've anounced the RELEASE_COMPLETE */
+ if (bc->channel>0)
+ empty_chan_in_stack(stack,bc->channel);
+ int tmpcause=bc->cause;
+ int tmp_out_cause=bc->out_cause;
+ empty_bc(bc);
+ bc->cause=tmpcause;
+ bc->out_cause=tmp_out_cause;
+ clean_up_bc(bc);
+ }
+
cb_log(5, stack->port, "Freeing Msg on prim:%x \n",frm->prim);
@@ -3189,21 +3200,40 @@
cb_log(5, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
}
+void misdn_send_lock(struct misdn_bchannel *bc);
+void misdn_send_unlock(struct misdn_bchannel *bc);
+
+#define RETURN(a,b) {retval=a; goto b;}
+
+void misdn_send_lock(struct misdn_bchannel *bc)
+{
+ //cb_log(0,bc->port,"Locking bc->pid:%d\n", bc->pid);
+ pthread_mutex_lock(&bc->send_lock->lock);
+}
+
+void misdn_send_unlock(struct misdn_bchannel *bc)
+{
+ //cb_log(0,bc->port,"UnLocking bc->pid:%d\n", bc->pid);
+ pthread_mutex_unlock(&bc->send_lock->lock);
+}
+
int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
{
msg_t *msg;
- int err = -1 ;
- int ret=0;
-
- if (!bc) goto ERR;
+ int retval=0;
+
+ if (!bc) RETURN(-1,OUT_POST_UNLOCK);
struct misdn_stack *stack=get_stack_by_bc(bc);
if (!stack) {
cb_log(0,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;
- }
-
+ RETURN(-1,OUT);
+ }
+
+ misdn_send_lock(bc);
+
+
cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id);
if ( stack->nt && !stack->l1link) {
@@ -3211,7 +3241,7 @@
bc->evq=event;
cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0));
misdn_lib_get_l1_up(stack);
- return 0;
+ RETURN(0,OUT);
}
cb_log(1, stack->port, "I SEND:%s oad:%s dad:%s pid:%d\n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad, bc->pid);
@@ -3223,8 +3253,7 @@
if (create_process(glob_mgr->midev, bc)<0) {
cb_log(0, stack->port, " No free channel at the moment @ send_event\n");
- err=-ENOCHAN;
- goto ERR;
+ RETURN(-ENOCHAN,OUT);
}
#if 0
if (stack->nt) {
@@ -3240,8 +3269,6 @@
case EVENT_ALERTING:
case EVENT_PROCEEDING:
case EVENT_SETUP_ACKNOWLEDGE:
- if (!bc->nt && !stack->ptp) break;
-
case EVENT_CONNECT:
case EVENT_RETRIEVE_ACKNOWLEDGE:
@@ -3250,21 +3277,19 @@
if (!find_free_chan_in_stack(stack, bc, 0,0)) {
cb_log(0, stack->port, " No free channel at the moment\n");
/*FIXME: add disconnect*/
- err=-ENOCHAN;
- goto ERR;
+ RETURN(-ENOCHAN,OUT);
}
if (set_chan_in_stack(stack ,bc->channel)<0) {
/*FIXME: add disconnect*/
- err=-ENOCHAN;
- goto ERR;
+ RETURN(-ENOCHAN,OUT);
}
}
/* Its that i generate channels */
}
- ret=setup_bc(bc);
- if (ret == -EINVAL) {
+ retval=setup_bc(bc);
+ if (retval == -EINVAL) {
cb_log(0,bc->port,"send_event: setup_bc failed\n");
}
@@ -3297,7 +3322,7 @@
struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel));
if (!holded_bc) {
cb_log(0,bc->port, "Could not allocate holded_bc!!!\n");
- return -1;
+ RETURN(-1,OUT);
}
/*backup the bc*/
@@ -3312,10 +3337,11 @@
if (bc->bc_state == BCHAN_BRIDGED) {
misdn_split_conf(bc,bc->conf_id);
struct misdn_bchannel *bc2=find_bc_by_confid(bc->conf_id);
- if (!bc2)
+ if (!bc2) {
cb_log(0,bc->port,"We have no second bc in bridge???\n");
- else
+ } else {
misdn_split_conf(bc2,bc->conf_id);
+ }
}
if (bc->channel>0)
@@ -3331,7 +3357,7 @@
case EVENT_DISCONNECT:
if (!bc->need_disconnect) {
cb_log(0,bc->port," --> we have already send Disconnect\n");
- return -1;
+ RETURN(-1,OUT);
}
bc->need_disconnect=0;
@@ -3339,7 +3365,7 @@
case EVENT_RELEASE:
if (!bc->need_release) {
cb_log(0,bc->port," --> we have already send Release\n");
- return -1;
+ RETURN(-1,OUT);
}
bc->need_disconnect=0;
bc->need_release=0;
@@ -3347,7 +3373,7 @@
case EVENT_RELEASE_COMPLETE:
if (!bc->need_release_complete) {
cb_log(0,bc->port," --> we have already send Release_complete\n");
- return -1;
+ RETURN(-1,OUT);
}
bc->need_disconnect=0;
bc->need_release=0;
@@ -3369,13 +3395,12 @@
case EVENT_CONNECT_ACKNOWLEDGE:
if ( bc->nt || misdn_cap_is_speech(bc->capability)) {
- int ret=setup_bc(bc);
- if (ret == -EINVAL){
+ int retval=setup_bc(bc);
+ if (retval == -EINVAL){
cb_log(0,bc->port,"send_event: setup_bc failed\n");
}
}
-
if (misdn_cap_is_speech(bc->capability)) {
if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0);
@@ -3401,10 +3426,11 @@
msg_queue_tail(&stack->downqueue, msg);
sem_post(&glob_mgr->new_msg);
- return 0;
-
- ERR:
- return -1;
+OUT:
+ misdn_send_unlock(bc);
+
+OUT_POST_UNLOCK:
+ return retval;
}
Modified: branches/1.4/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/misdn/isdn_lib.h?view=diff&rev=62912&r1=62911&r2=62912
==============================================================================
--- branches/1.4/channels/misdn/isdn_lib.h (original)
+++ branches/1.4/channels/misdn/isdn_lib.h Thu May 3 09:36:32 2007
@@ -199,6 +199,7 @@
struct misdn_bchannel {
+ struct send_lock *send_lock;
int nt;
int port;
Modified: branches/1.4/channels/misdn/isdn_lib_intern.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/misdn/isdn_lib_intern.h?view=diff&rev=62912&r1=62911&r2=62912
==============================================================================
--- branches/1.4/channels/misdn/isdn_lib_intern.h (original)
+++ branches/1.4/channels/misdn/isdn_lib_intern.h Thu May 3 09:36:32 2007
@@ -28,6 +28,10 @@
ibuffer_t *astbuf;
ibuffer_t *misdnbuf;
+
+struct send_lock {
+ pthread_mutex_t lock;
+};
struct isdn_msg {
Modified: branches/1.4/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/misdn/isdn_msg_parser.c?view=diff&rev=62912&r1=62911&r2=62912
==============================================================================
--- branches/1.4/channels/misdn/isdn_msg_parser.c (original)
+++ branches/1.4/channels/misdn/isdn_msg_parser.c Thu May 3 09:36:32 2007
@@ -296,6 +296,10 @@
enc_ie_redir_nr(&setup->REDIR_NR, msg, 1, 1, bc->pres, bc->screen, 0, bc->rad, nt,bc);
}
+ {
+ if (bc->keypad[0])
+ enc_ie_keypad(&setup->CALLED_PN, msg, bc->keypad, nt,bc);
+ }
if (*bc->display) {
More information about the asterisk-commits
mailing list