[asterisk-commits] irroot: branch irroot/distrotech-customers-trunk r320771 - /team/irroot/distr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 25 09:32:56 CDT 2011


Author: irroot
Date: Wed May 25 09:32:50 2011
New Revision: 320771

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=320771
Log:
Some locking sanity for format changes

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

Modified: team/irroot/distrotech-customers-trunk/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/channels/chan_local.c?view=diff&rev=320771&r1=320770&r2=320771
==============================================================================
--- team/irroot/distrotech-customers-trunk/channels/chan_local.c (original)
+++ team/irroot/distrotech-customers-trunk/channels/chan_local.c Wed May 25 09:32:50 2011
@@ -526,25 +526,28 @@
 		return -1;
 
 	/* Just queue for delivery to the other side */
-	while(ao2_trylock(p)) {
-		CHANNEL_DEADLOCK_AVOIDANCE(ast);
-	}
+	ao2_lock(p);
 	ao2_ref(p, 1); /* ref for local_queue_frame */
 
-	/* fixup formats nativeformat has changed we must adjust */
-	bridge = ast_bridged_channel(p->owner);
-	if (bridge && !ast_format_cap_identical(bridge->nativeformats, p->owner->nativeformats)) {
-		ast_format_cap_copy(bridge->nativeformats, p->chan->nativeformats);
-		ast_format_cap_copy(bridge->nativeformats, p->owner->nativeformats);
-		ast_set_read_format(p->owner, &p->owner->readformat);
-		ast_set_write_format(p->owner, &p->owner->writeformat);
-		ast_set_read_format(p->chan, &p->chan->readformat);
-		ast_set_write_format(p->chan, &p->chan->writeformat);
-	}
-
 	isoutbound = IS_OUTBOUND(ast, p);
-	if (isoutbound && f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO))
+	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
+		 * 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);
+		}
+	}
+
 	if (!ast_test_flag(p, LOCAL_ALREADY_MASQED))
 		res = local_queue_frame(p, isoutbound, f, ast, 1);
 	else {




More information about the asterisk-commits mailing list