[Asterisk-code-review] ari: Ignore invisible bridges when listing bridges. (asterisk[19])

Kevin Harwell asteriskteam at digium.com
Fri Sep 24 10:59:16 CDT 2021


Kevin Harwell has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/16541 )

Change subject: ari: Ignore invisible bridges when listing bridges.
......................................................................

ari: Ignore invisible bridges when listing bridges.

When listing bridges we go through the ones present in
ARI, get their snapshot, turn it into JSON, and add it
to the payload we ultimately return.

An invisible "dial bridge" exists within ARI that would
also try to be added to this payload if the channel
"create" and "dial" routes were used. This would ultimately
fail due to invisible bridges having no snapshot
resulting in the listing of bridges failing.

This change makes it so that the listing of bridges
ignores invisible ones.

ASTERISK-29668

Change-Id: I14fa4b589b4657d1c2a5226b0f527f45a0cd370a
---
M res/ari/resource_bridges.c
1 file changed, 15 insertions(+), 4 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c
index e4e7064..d03e86f 100644
--- a/res/ari/resource_bridges.c
+++ b/res/ari/resource_bridges.c
@@ -905,12 +905,23 @@
 
 	i = ao2_iterator_init(bridges, 0);
 	while ((bridge = ao2_iterator_next(&i))) {
-		struct ast_bridge_snapshot *snapshot = ast_bridge_get_snapshot(bridge);
-		/* ast_bridge_snapshot_to_json will return NULL if snapshot is NULL */
-		struct ast_json *json_bridge = ast_bridge_snapshot_to_json(snapshot, stasis_app_get_sanitizer());
+		struct ast_bridge_snapshot *snapshot;
+		struct ast_json *json_bridge = NULL;
+
+		/* Invisible bridges don't get shown externally and have no snapshot */
+		if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_INVISIBLE)) {
+			ao2_ref(bridge, -1);
+			continue;
+		}
+
+		snapshot = ast_bridge_get_snapshot(bridge);
+		if (snapshot) {
+			json_bridge = ast_bridge_snapshot_to_json(snapshot, stasis_app_get_sanitizer());
+			ao2_ref(snapshot, -1);
+		}
 
 		ao2_ref(bridge, -1);
-		ao2_cleanup(snapshot);
+
 		if (!json_bridge || ast_json_array_append(json, json_bridge)) {
 			ao2_iterator_destroy(&i);
 			ast_ari_response_alloc_failed(response);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16541
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I14fa4b589b4657d1c2a5226b0f527f45a0cd370a
Gerrit-Change-Number: 16541
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210924/69104d3d/attachment.html>


More information about the asterisk-code-review mailing list