[svn-commits] russell: branch 1.6.0 r119690 - in /branches/1.6.0: ./ channels/misdn/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 2 07:32:23 CDT 2008


Author: russell
Date: Mon Jun  2 07:32:22 2008
New Revision: 119690

URL: http://svn.digium.com/view/asterisk?view=rev&rev=119690
Log:
Merged revisions 119586,119637 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r119586 | crichter | 2008-06-02 03:46:23 -0500 (Mon, 02 Jun 2008) | 9 lines

Merged revisions 119585 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r119585 | crichter | 2008-06-02 10:35:28 +0200 (Mo, 02 Jun 2008) | 1 line

Added counter for unhandled_bmsg Print, this prevents the logs to be flooded to fast and save CPU in this error scenario. Added 'last_used' element to bc structure, when a bchannel changes from used to free this exact time will be marked in last_used. When a new channel is requested the find_free_chan function will check if the new empty channel was used within the last second, if yes it will search for the next channel, if no it will return this channel. This simple mechanism has prooven to prevent race conditions where the NT and TE tried to allocate the exact same channel at the same time (RELEASE cause: 44).
........

................
r119637 | crichter | 2008-06-02 04:35:04 -0500 (Mon, 02 Jun 2008) | 9 lines

Merged revisions 119636 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r119636 | crichter | 2008-06-02 11:29:21 +0200 (Mo, 02 Jun 2008) | 1 line

fixed compile issue when dev-mode is enabled
........

................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/channels/misdn/isdn_lib.c
    branches/1.6.0/channels/misdn/isdn_lib.h

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/misdn/isdn_lib.c?view=diff&rev=119690&r1=119689&r2=119690
==============================================================================
--- branches/1.6.0/channels/misdn/isdn_lib.c (original)
+++ branches/1.6.0/channels/misdn/isdn_lib.c Mon Jun  2 07:32:22 2008
@@ -19,6 +19,7 @@
 
 
 #include <syslog.h>
+#include <sys/time.h>
 #include <mISDNuser/isdn_debug.h>
 
 #include "isdn_lib_intern.h"
@@ -719,6 +720,8 @@
 	
 	bc->te_choose_channel = 0;
 	bc->channel_found= 0;
+
+	gettimeofday(&bc->last_used, NULL);
 }
 
 
@@ -1578,7 +1581,17 @@
 					break;
 				}
 
-				cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
+				if (!bc->channel)
+					cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
+				else 
+					cb_log(0, stack->port, "Requested Channel Already in Use releasing this call with cause 34!!!!\n");
+
+				/* when the channel is already in use, we can't
+				 * simply clear it, we need to make sure that 
+				 * it will still be marked as in_use in the 
+				 * available channels list.*/
+				bc->channel=0;
+
 				misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 				return -1;
 			}
@@ -3103,6 +3116,20 @@
 
 
 
+static int test_inuse(struct misdn_bchannel *bc)
+{
+	struct timeval now;
+	gettimeofday(&now, NULL);
+	if (!bc->in_use) {
+		if (bc->last_used.tv_sec < now.tv_sec) {
+			cb_log(0,bc->port, "channel with stid:%x for one second still in use!\n", bc->b_stid);
+			return 1;
+		}
+	}
+	return 0;
+}
+
+
 static void prepare_bc(struct misdn_bchannel*bc, int channel)
 {
 	bc->channel = channel;
@@ -3133,6 +3160,8 @@
 		return NULL;
 	}
 
+	usleep(1000);
+
 	for (stack=glob_mgr->stack_list; stack; stack=stack->next) {
     
 		if (stack->port == port) {
@@ -3146,7 +3175,7 @@
 			if (channel > 0) {
 				if (channel <= stack->b_num) {
 					for (i = 0; i < stack->b_num; i++) {
-						if (stack->bc[i].in_use && stack->bc[i].channel == channel) {
+						if ( test_inuse(&stack->bc[i]) && stack->bc[i].channel == channel) {
 							cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
 							return NULL;
 						}
@@ -3161,7 +3190,7 @@
 
 			if (dec) {
 				for (i = maxnum-1; i>=0; i--) {
-					if (!stack->bc[i].in_use) {
+					if (test_inuse(&stack->bc[i])) {
 						/* 3. channel on bri means CW*/
 						if (!stack->pri && i==stack->b_num)
 							stack->bc[i].cw=1;
@@ -3173,7 +3202,7 @@
 				}
 			} else {
 				for (i = 0; i <maxnum; i++) {
-					if (!stack->bc[i].in_use) {
+					if (test_inuse(&stack->bc[i])) {
 						/* 3. channel on bri means CW*/
 						if (!stack->pri && i==stack->b_num)
 							stack->bc[i].cw=1;
@@ -3595,9 +3624,19 @@
 	}
 
 	if ( ((frm->addr | ISDN_PID_BCHANNEL_BIT )>> 28 ) == 0x5) {
+		static int unhandled_bmsg_count=1000;
 		if (handle_bchan(msg)) {
 			return 0 ;
 		}
+			
+		if (unhandled_bmsg_count==1000) {
+			cb_log(0, 0, "received 1k Unhandled Bchannel Messages: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo);		
+			unhandled_bmsg_count=0;
+		}
+
+		unhandled_bmsg_count++;
+		free_msg(msg);
+		return 0;
 	}	
 
 #ifdef RECV_FRM_SYSLOG_DEBUG

Modified: branches/1.6.0/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/misdn/isdn_lib.h?view=diff&rev=119690&r1=119689&r2=119690
==============================================================================
--- branches/1.6.0/channels/misdn/isdn_lib.h (original)
+++ branches/1.6.0/channels/misdn/isdn_lib.h Mon Jun  2 07:32:22 2008
@@ -236,6 +236,7 @@
 	int channel_preselected;
 	
 	int in_use;
+	struct timeval last_used;
 	int cw;
 	int addr;
 




More information about the svn-commits mailing list