[asterisk-commits] crichter: branch 1.2 r72585 - in /branches/1.2/channels: ./ misdn/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 29 08:08:27 CDT 2007


Author: crichter
Date: Fri Jun 29 08:08:26 2007
New Revision: 72585

URL: http://svn.digium.com/view/asterisk?view=rev&rev=72585
Log:
check if the bchannel stack id is already used, if so don't use it a second time. Also added a release_chan lock, so that the same chan_list object cannot be freed twice. chan_misdn does not crash anymore on heavy load with these changes.

Modified:
    branches/1.2/channels/chan_misdn.c
    branches/1.2/channels/misdn/isdn_lib.c

Modified: branches/1.2/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_misdn.c?view=diff&rev=72585&r1=72584&r2=72585
==============================================================================
--- branches/1.2/channels/chan_misdn.c (original)
+++ branches/1.2/channels/chan_misdn.c Fri Jun 29 08:08:26 2007
@@ -103,6 +103,7 @@
 
 /* BEGIN: chan_misdn.h */
 
+ast_mutex_t release_lock;
 
 
 enum misdn_chan_state {
@@ -3286,10 +3287,13 @@
 /** Isdn asks us to release channel, pendant to misdn_hangup **/
 static void release_chan(struct misdn_bchannel *bc) {
 	struct ast_channel *ast=NULL;
+
+	ast_mutex_lock(&release_lock);
 	{
 		struct chan_list *ch=find_chan_by_bc(cl_te, bc);
 		if (!ch)  {
 			chan_misdn_log(1, bc->port, "release_chan: Ch not found!\n");
+			ast_mutex_unlock(&release_lock);
 			return;
 		}
 		
@@ -3341,6 +3345,8 @@
 			/* chan is already cleaned, so exiting  */
 		}
 	}
+
+	ast_mutex_unlock(&release_lock);
 }
 /*** release end **/
 
@@ -4537,6 +4543,7 @@
 	}
 
 	ast_mutex_init(&cl_te_lock);
+	ast_mutex_init(&release_lock);
 
 	misdn_cfg_update_ptp();
 	misdn_cfg_get_ports_string(ports);

Modified: branches/1.2/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/misdn/isdn_lib.c?view=diff&rev=72585&r1=72584&r2=72585
==============================================================================
--- branches/1.2/channels/misdn/isdn_lib.c (original)
+++ branches/1.2/channels/misdn/isdn_lib.c Fri Jun 29 08:08:26 2007
@@ -966,7 +966,7 @@
 	int channel=bc->channel-1-(bc->channel>16);
 	int b_stid=stack->b_stids[channel>=0?channel:0];
 
-
+	
 	switch (bc->bc_state) {
 		case BCHAN_CLEANED:
 			break;
@@ -976,6 +976,15 @@
 	}
 	
 	cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid);
+	
+	/*check if the b_stid is alread initialized*/
+	int i;
+	for (i=0; i <= stack->b_num; i++) {
+		if (stack->bc[i].b_stid == b_stid) {
+			cb_log(0, bc->port, "setup_bc: b_stid:%x already in use !!!\n", b_stid);
+			return -1;
+		}
+	}
 	
 	if (b_stid <= 0) {
 		cb_log(0, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel);




More information about the asterisk-commits mailing list