[asterisk-commits] mnicholson: branch 1.8 r335431 - /branches/1.8/bridges/bridge_multiplexed.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 12 10:49:28 CDT 2011
Author: mnicholson
Date: Mon Sep 12 10:49:24 2011
New Revision: 335431
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=335431
Log:
Prevent a race condition when the bridge technology changes. This change was
ported from asterisk 10.
ASTERISK-18155
Modified:
branches/1.8/bridges/bridge_multiplexed.c
Modified: branches/1.8/bridges/bridge_multiplexed.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/bridges/bridge_multiplexed.c?view=diff&rev=335431&r1=335430&r2=335431
==============================================================================
--- branches/1.8/bridges/bridge_multiplexed.c (original)
+++ branches/1.8/bridges/bridge_multiplexed.c Mon Sep 12 10:49:24 2011
@@ -223,6 +223,9 @@
winner = ast_waitfor_nandfds(multiplexed_thread->chans, multiplexed_thread->service_count, &fds, 1, NULL, &outfd, &to);
multiplexed_thread->waiting = 0;
ao2_lock(multiplexed_thread);
+ if (multiplexed_thread->thread == AST_PTHREADT_STOP) {
+ break;
+ }
if (outfd > -1) {
int nudge;
@@ -234,7 +237,21 @@
}
}
if (winner && winner->bridge) {
- ast_bridge_handle_trip(winner->bridge, NULL, winner, -1);
+ struct ast_bridge *bridge = winner->bridge;
+ int stop = 0;
+ ao2_unlock(multiplexed_thread);
+ while ((bridge = winner->bridge) && ao2_trylock(bridge)) {
+ sched_yield();
+ if (multiplexed_thread->thread == AST_PTHREADT_STOP) {
+ stop = 1;
+ break;
+ }
+ }
+ if (!stop && bridge) {
+ ast_bridge_handle_trip(bridge, NULL, winner, -1);
+ ao2_unlock(bridge);
+ }
+ ao2_lock(multiplexed_thread);
}
}
More information about the asterisk-commits
mailing list