[asterisk-commits] irroot: branch irroot/distrotech-customers-trunk r338030 - /team/irroot/distr...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 27 04:32:26 CDT 2011
Author: irroot
Date: Tue Sep 27 04:32:22 2011
New Revision: 338030
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=338030
Log:
Deadlock avoidance for chan_local fixup
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=338030&r1=338029&r2=338030
==============================================================================
--- team/irroot/distrotech-customers-trunk/channels/chan_local.c (original)
+++ team/irroot/distrotech-customers-trunk/channels/chan_local.c Tue Sep 27 04:32:22 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 && !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