[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r338028 - /team/irroot/distrot...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 27 04:00:31 CDT 2011


Author: irroot
Date: Tue Sep 27 04:00:27 2011
New Revision: 338028

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=338028
Log:
Deadlock avoidance for chan_local fixup

Modified:
    team/irroot/distrotech-customers-1.8/channels/chan_local.c

Modified: team/irroot/distrotech-customers-1.8/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/channels/chan_local.c?view=diff&rev=338028&r1=338027&r2=338028
==============================================================================
--- team/irroot/distrotech-customers-1.8/channels/chan_local.c (original)
+++ team/irroot/distrotech-customers-1.8/channels/chan_local.c Tue Sep 27 04:00:27 2011
@@ -591,6 +591,7 @@
 	struct ast_channel *bridge;
 	int res = -1;
 	int isoutbound;
+	int lockcheck = 10;
 
 	if (!p) {
 		return -1;
@@ -603,19 +604,24 @@
 
 	if (isoutbound && f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
 		check_bridge(p);
-	} else if (!isoutbound) {
-		/* fixup formats nativeformat has changed we must adjust
+	} else if (f && (f->frametype == AST_FRAME_VOICE)) {
+		/* fixup audio formats nativeformat has changed we must adjust
 		 * ast is p->owner and is locked here*/
 		bridge = ast_bridged_channel(ast);
 		if (bridge && !(bridge->nativeformats & ast->nativeformats)) {
-			ast->nativeformats = bridge->nativeformats;
-			ast_set_read_format(ast, ast->readformat);
-			ast_set_write_format(ast, ast->writeformat);
-			ast_channel_lock(p->chan);
-			p->chan->nativeformats = bridge->nativeformats;
-			ast_set_read_format(p->chan, p->chan->readformat);
-			ast_set_write_format(p->chan, p->chan->writeformat);
-			ast_channel_unlock(p->chan);
+			while (lockcheck && ast_channel_trylock(p->chan)) {
+				lockcheck--;
+				usleep(1000);
+			}
+			if (lockcheck) {
+				ast->nativeformats = bridge->nativeformats;
+				ast_set_read_format(ast, ast->readformat);
+				ast_set_write_format(ast, ast->writeformat);
+				p->chan->nativeformats = bridge->nativeformats;
+				ast_set_read_format(p->chan, p->chan->readformat);
+				ast_set_write_format(p->chan, p->chan->writeformat);
+				ast_channel_unlock(p->chan);
+			}
 		}
 	}
 




More information about the asterisk-commits mailing list