mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-28 07:01:07 +00:00
Prevent a race condition when the bridge technology changes. This change was
ported from asterisk 10. ASTERISK-18155 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335431 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -223,6 +223,9 @@ static void *multiplexed_thread_function(void *data)
|
|||||||
winner = ast_waitfor_nandfds(multiplexed_thread->chans, multiplexed_thread->service_count, &fds, 1, NULL, &outfd, &to);
|
winner = ast_waitfor_nandfds(multiplexed_thread->chans, multiplexed_thread->service_count, &fds, 1, NULL, &outfd, &to);
|
||||||
multiplexed_thread->waiting = 0;
|
multiplexed_thread->waiting = 0;
|
||||||
ao2_lock(multiplexed_thread);
|
ao2_lock(multiplexed_thread);
|
||||||
|
if (multiplexed_thread->thread == AST_PTHREADT_STOP) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (outfd > -1) {
|
if (outfd > -1) {
|
||||||
int nudge;
|
int nudge;
|
||||||
@@ -234,7 +237,21 @@ static void *multiplexed_thread_function(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (winner && winner->bridge) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user