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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 2 04:34:22 CDT 2007


Author: crichter
Date: Mon Jul  2 04:34:19 2007
New Revision: 72869

URL: http://svn.digium.com/view/asterisk?view=rev&rev=72869
Log:
Merged revisions 72852 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r72852 | crichter | 2007-07-02 10:41:08 +0200 (Mo, 02 Jul 2007) | 9 lines

Merged revisions 72585 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r72585 | crichter | 2007-06-29 15:08:26 +0200 (Fr, 29 Jun 2007) | 1 line

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:
    trunk/   (props changed)
    trunk/channels/chan_misdn.c
    trunk/channels/misdn/isdn_lib.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?view=diff&rev=72869&r1=72868&r2=72869
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Mon Jul  2 04:34:19 2007
@@ -113,6 +113,10 @@
 of data. */
 int misdn_jb_empty(struct misdn_jb *jb, char *data, int len);
 
+
+/* BEGIN: chan_misdn.h */
+
+ast_mutex_t release_lock;
 
 enum misdn_chan_state {
 	MISDN_NOTHING=0,	/*!< at beginning */
@@ -2326,11 +2330,13 @@
 		/* between request and call */
 		ast_debug(1, "State Reserved (or nothing) => chanIsAvail\n");
 		MISDN_ASTERISK_TECH_PVT(ast) = NULL;
-		
+	
+		ast_mutex_lock(&release_lock);
 		cl_dequeue_chan(&cl_te, p);
 		close(p->pipe[0]);
 		close(p->pipe[1]);
 		ast_free(p);
+		ast_mutex_unlock(&release_lock);
 		
 		if (bc)
 			misdn_lib_release(bc);
@@ -3388,67 +3394,73 @@
 
 /** Isdn asks us to release channel, pendant to misdn_hangup **/
 static void release_chan(struct misdn_bchannel *bc) {
-	struct ast_channel *ast = NULL;
-	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");
-		return;
-	}
-		
-	if (ch->ast) {
-		ast = ch->ast;
-	} 
-		
-	chan_misdn_log(5, bc->port, "release_chan: bc with l3id: %x\n", bc->l3_id);
-		
-	/*releaseing jitterbuffer*/
-	if (ch->jb ) {
-		misdn_jb_destroy(ch->jb);
-		ch->jb = NULL;
-	} else {
-		if (!bc->nojitter)
-			chan_misdn_log(5, bc->port, "Jitterbuffer already destroyed.\n");
-	}
-
-	if (ch->overlap_dial) {
-		if (ch->overlap_dial_task != -1) {
-			misdn_tasks_remove(ch->overlap_dial_task);
-			ch->overlap_dial_task = -1;
-		}
-		ast_mutex_destroy(&ch->overlap_tv_lock);
-	}
-
-	if (ch->originator == ORG_AST) {
-		misdn_out_calls[bc->port]--;
-	} else {
-		misdn_in_calls[bc->port]--;
-	}
-		
-	if (ch) {
-		close(ch->pipe[0]);
-		close(ch->pipe[1]);
-
-		if (ast && MISDN_ASTERISK_TECH_PVT(ast)) {
-			chan_misdn_log(1, bc->port, "* RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s\n", bc ? bc->pid : -1, ast->context, ast->exten, ast->cid.cid_num, misdn_get_ch_state(ch));
-			chan_misdn_log(3, bc->port, " --> * State Down\n");
-			MISDN_ASTERISK_TECH_PVT(ast) = NULL;
-
-			if (ast->_state != AST_STATE_RESERVED) {
-				chan_misdn_log(3, bc->port, " --> Setting AST State to down\n");
-				ast_setstate(ast, AST_STATE_DOWN);
+	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;
+		}
+
+		if (ch->ast) {
+			ast = ch->ast;
+		} 
+
+		chan_misdn_log(5, bc->port, "release_chan: bc with l3id: %x\n", bc->l3_id);
+
+		/*releaseing jitterbuffer*/
+		if (ch->jb ) {
+			misdn_jb_destroy(ch->jb);
+			ch->jb = NULL;
+		} else {
+			if (!bc->nojitter)
+				chan_misdn_log(5, bc->port, "Jitterbuffer already destroyed.\n");
+		}
+
+		if (ch->overlap_dial) {
+			if (ch->overlap_dial_task != -1) {
+				misdn_tasks_remove(ch->overlap_dial_task);
+				ch->overlap_dial_task = -1;
 			}
-		}
-
-		ch->state = MISDN_CLEANING;
-		cl_dequeue_chan(&cl_te, ch);
-
-		ast_free(ch);
-	} else {
-		/* chan is already cleaned, so exiting  */
-	}
-}
+			ast_mutex_destroy(&ch->overlap_tv_lock);
+		}
+
+		if (ch->originator == ORG_AST) {
+			misdn_out_calls[bc->port]--;
+		} else {
+			misdn_in_calls[bc->port]--;
+		}
+
+		if (ch) {
+			close(ch->pipe[0]);
+			close(ch->pipe[1]);
+
+			if (ast && MISDN_ASTERISK_TECH_PVT(ast)) {
+				chan_misdn_log(1, bc->port, "* RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s\n", bc ? bc->pid : -1, ast->context, ast->exten, ast->cid.cid_num, misdn_get_ch_state(ch));
+				chan_misdn_log(3, bc->port, " --> * State Down\n");
+				MISDN_ASTERISK_TECH_PVT(ast) = NULL;
+
+				if (ast->_state != AST_STATE_RESERVED) {
+					chan_misdn_log(3, bc->port, " --> Setting AST State to down\n");
+					ast_setstate(ast, AST_STATE_DOWN);
+				}
+			}
+
+			ch->state = MISDN_CLEANING;
+			cl_dequeue_chan(&cl_te, ch);
+
+			ast_free(ch);
+		} else {
+			/* chan is already cleaned, so exiting  */
+		}
+
+		ast_mutex_unlock(&release_lock);
+	}
 /*** release end **/
+}
 
 static void misdn_transfer_bc(struct chan_list *tmp_ch, struct chan_list *holded_chan)
 {
@@ -4771,6 +4783,7 @@
 	}
 
 	ast_mutex_init(&cl_te_lock);
+	ast_mutex_init(&release_lock);
 
 	misdn_cfg_update_ptp();
 	misdn_cfg_get_ports_string(ports);

Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?view=diff&rev=72869&r1=72868&r2=72869
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Mon Jul  2 04:34:19 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