Better handle clearing the OUTGOING flag when a channel leaves a bridge
[asterisk/asterisk.git] / main / bridge_channel.c
index 92ad660..1aa82ab 100644 (file)
@@ -1527,8 +1527,9 @@ void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel)
         * outgoing channel, clear the outgoing flag.
         */
        if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING)
         * outgoing channel, clear the outgoing flag.
         */
        if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING)
-                       && (ast_channel_softhangup_internal_flag(bridge_channel->chan) &
-                               (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE))) {
+                       && (ast_channel_softhangup_internal_flag(bridge_channel->chan) & (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE)
+                           || bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT)) {
+               ast_debug(2, "Channel %s will survive this bridge; clearing outgoing (dialed) flag\n", ast_channel_name(bridge_channel->chan));
                ast_clear_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING);
        }
 
                ast_clear_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING);
        }