[asterisk-commits] irroot: branch irroot/distrotech-customers-10 r338029 - /team/irroot/distrote...

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


Author: irroot
Date: Tue Sep 27 04:09:24 2011
New Revision: 338029

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

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

Modified: team/irroot/distrotech-customers-10/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/channels/chan_local.c?view=diff&rev=338029&r1=338028&r2=338029
==============================================================================
--- team/irroot/distrotech-customers-10/channels/chan_local.c (original)
+++ team/irroot/distrotech-customers-10/channels/chan_local.c Tue Sep 27 04:09:24 2011
@@ -590,6 +590,7 @@
 	struct ast_channel *bridge;
 	int res = -1;
 	int isoutbound;
+	int lockcheck = 10;
 
 	if (!p) {
 		return -1;
@@ -602,19 +603,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 && !ast_format_cap_identical(bridge->nativeformats, ast->nativeformats)) {
-			ast_format_cap_copy(bridge->nativeformats, p->owner->nativeformats);
-			ast_set_read_format(ast, &ast->readformat);
-			ast_set_write_format(ast, &ast->writeformat);
-			ast_channel_lock(p->chan);
-			ast_format_cap_copy(bridge->nativeformats, p->chan->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_format_cap_copy(bridge->nativeformats, p->owner->nativeformats);
+				ast_set_read_format(ast, &ast->readformat);
+				ast_set_write_format(ast, &ast->writeformat);
+				ast_format_cap_copy(bridge->nativeformats, p->chan->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