]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
bridge_simple.c: Unhold channels on join simple bridge.
authorYury Kirsanov <y.kirsanov@gmail.com>
Thu, 21 Apr 2022 14:10:40 +0000 (10:10 -0400)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Tue, 26 Apr 2022 20:01:43 +0000 (15:01 -0500)
Patch provided inline by Yury Kirsanov on the linked issue and
approved by Josh Colp.

ASTERISK-29253 #close

Change-Id: I5b9ccc67ebf06e875ed061d9e7fc21f47b0a4e1f

bridges/bridge_simple.c

index 1e224f782b0d1c8ad0749b6af6c0a9f6f5d4877d..ba300ed4d3f9520c073b20c80062921cf33a0166 100644 (file)
@@ -128,6 +128,7 @@ static int simple_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chann
        struct ast_stream_topology *new_top;
        struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan;
        struct ast_channel *c1 = AST_LIST_LAST(&bridge->channels)->chan;
+       int unhold_c0, unhold_c1;
 
        /*
         * If this is the first channel we can't make it compatible...
@@ -152,9 +153,29 @@ static int simple_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chann
                SWAP(c0, c1);
        }
        new_top = simple_bridge_request_stream_topology_update(existing_top, req_top);
+
+       /* The ast_channel_hold_state() and ast_channel_name() accessors need to be
+        * called with the associated channel lock held.
+        */
+       if ((unhold_c1 = ast_channel_hold_state(c1) == AST_CONTROL_HOLD)) {
+               ast_debug(1, "Channel %s simulating UNHOLD for bridge simple join.\n", ast_channel_name(c1));
+       }
+
+       if ((unhold_c0 = ast_channel_hold_state(c0) == AST_CONTROL_HOLD)) {
+               ast_debug(1, "Channel %s simulating UNHOLD for bridge simple join.\n", ast_channel_name(c0));
+       }
+
        ast_channel_unlock(c0);
        ast_channel_unlock(c1);
 
+       if (unhold_c1) {
+               ast_indicate(c1, AST_CONTROL_UNHOLD);
+       }
+
+       if (unhold_c0) {
+               ast_indicate(c0, AST_CONTROL_UNHOLD);
+       }
+
        if (!new_top) {
                /* Failure.  We'll just have to live with the current topology. */
                return 0;