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

Joshua Colp asteriskteam at digium.com
Thu Sep 23 09:19:39 CDT 2021


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/16542 )


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(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/42/16542/1

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/+/16542
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I14fa4b589b4657d1c2a5226b0f527f45a0cd370a
Gerrit-Change-Number: 16542
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210923/1fc314f3/attachment.html>


More information about the asterisk-code-review mailing list