*/
static void bridges_scrape_cb(struct ast_str **response)
{
+ struct ao2_container *bridge_cache;
struct ao2_container *bridges;
struct ao2_iterator it_bridges;
struct ast_bridge *bridge;
ast_eid_to_str(eid_str, sizeof(eid_str), &ast_eid_default);
- bridges = ast_bridges();
+ bridge_cache = ast_bridges();
+ if (!bridge_cache) {
+ return;
+ }
+
+ bridges = ao2_container_clone(bridge_cache, 0);
+ ao2_ref(bridge_cache, -1);
if (!bridges) {
return;
}
+
num_bridges = ao2_container_count(bridges);
/* Current endpoint count */
prometheus_callback_register(&bridges_callback);
return 0;
-}
\ No newline at end of file
+}
*/
static void channels_scrape_cb(struct ast_str **response)
{
+ struct ao2_container *channel_cache;
struct ao2_container *channels;
struct ao2_iterator it_chans;
struct ast_channel_snapshot *snapshot;
ast_eid_to_str(eid_str, sizeof(eid_str), &ast_eid_default);
- channels = ast_channel_cache_all();
+ channel_cache = ast_channel_cache_all();
+ if (!channel_cache) {
+ return;
+ }
+
+ channels = ao2_container_clone(channel_cache, 0);
+ ao2_ref(channel_cache, -1);
+ if (!channels) {
+ return;
+ }
+
num_channels = ao2_container_count(channels);
/* Channel count */
prometheus_callback_register(&channels_callback);
return 0;
-}
\ No newline at end of file
+}
*/
static void endpoints_scrape_cb(struct ast_str **response)
{
+ struct ao2_container *endpoint_cache;
struct ao2_container *endpoints;
struct ao2_iterator it_endpoints;
struct stasis_message *message;
ast_eid_to_str(eid_str, sizeof(eid_str), &ast_eid_default);
- endpoints = stasis_cache_dump(ast_endpoint_cache(), ast_endpoint_snapshot_type());
+ endpoint_cache = stasis_cache_dump(ast_endpoint_cache(), ast_endpoint_snapshot_type());
+ if (!endpoint_cache) {
+ return;
+ }
+ endpoints = ao2_container_clone(endpoint_cache, 0);
+ ao2_ref(endpoint_cache, -1);
if (!endpoints) {
return;
}
+
num_endpoints = ao2_container_count(endpoints);
/* Current endpoint count */