diff options
Diffstat (limited to 'bridges/bridge_multiplexed.c')
-rw-r--r-- | bridges/bridge_multiplexed.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/bridges/bridge_multiplexed.c b/bridges/bridge_multiplexed.c index 0d2b3e254..5a3de43d8 100644 --- a/bridges/bridge_multiplexed.c +++ b/bridges/bridge_multiplexed.c @@ -219,6 +219,9 @@ static void *multiplexed_thread_function(void *data) 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; @@ -230,7 +233,21 @@ static void *multiplexed_thread_function(void *data) } } 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); } } |