mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
res_pjsip_pubsub.c: Fix AMI event list counts.
Fix the AMI PJSIPShowSubscriptionsInbound, PJSIPShowSubscriptionsOutbound, and PJSIPShowResourceLists actions event counts. The reported counts may not necessarily be accurate depending on what happens. The subscriptions count would be wrong if Asterisk ever has outbound subscriptions. The resource list count could be wrong if a list were added or removed during the AMI action being processed. Change-Id: I4344301827523fa174960a42c413fd19abe4aed5
This commit is contained in:
@@ -3586,6 +3586,8 @@ static int ami_subscription_detail(struct sip_subscription_tree *sub_tree,
|
||||
sip_subscription_to_ami(sub_tree, &buf);
|
||||
astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
|
||||
ast_free(buf);
|
||||
|
||||
++ami->count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3604,14 +3606,13 @@ static int ami_subscription_detail_outbound(struct sip_subscription_tree *sub_tr
|
||||
static int ami_show_subscriptions_inbound(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
|
||||
int num;
|
||||
|
||||
astman_send_listack(s, m, "Following are Events for each inbound Subscription",
|
||||
"start");
|
||||
|
||||
num = for_each_subscription(ami_subscription_detail_inbound, &ami);
|
||||
for_each_subscription(ami_subscription_detail_inbound, &ami);
|
||||
|
||||
astman_send_list_complete_start(s, m, "InboundSubscriptionDetailComplete", num);
|
||||
astman_send_list_complete_start(s, m, "InboundSubscriptionDetailComplete", ami.count);
|
||||
astman_send_list_complete_end(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -3619,14 +3620,13 @@ static int ami_show_subscriptions_inbound(struct mansession *s, const struct mes
|
||||
static int ami_show_subscriptions_outbound(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
|
||||
int num;
|
||||
|
||||
astman_send_listack(s, m, "Following are Events for each outbound Subscription",
|
||||
"start");
|
||||
|
||||
num = for_each_subscription(ami_subscription_detail_outbound, &ami);
|
||||
for_each_subscription(ami_subscription_detail_outbound, &ami);
|
||||
|
||||
astman_send_list_complete_start(s, m, "OutboundSubscriptionDetailComplete", num);
|
||||
astman_send_list_complete_start(s, m, "OutboundSubscriptionDetailComplete", ami.count);
|
||||
astman_send_list_complete_end(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -3647,21 +3647,21 @@ static int format_ami_resource_lists(void *obj, void *arg, int flags)
|
||||
return CMP_STOP;
|
||||
}
|
||||
astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
|
||||
|
||||
ast_free(buf);
|
||||
|
||||
++ami->count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ami_show_resource_lists(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
|
||||
int num;
|
||||
struct ao2_container *lists;
|
||||
|
||||
lists = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "resource_list",
|
||||
AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);
|
||||
|
||||
if (!lists || !(num = ao2_container_count(lists))) {
|
||||
if (!lists || !ao2_container_count(lists)) {
|
||||
astman_send_error(s, m, "No resource lists found\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -3671,7 +3671,7 @@ static int ami_show_resource_lists(struct mansession *s, const struct message *m
|
||||
|
||||
ao2_callback(lists, OBJ_NODATA, format_ami_resource_lists, &ami);
|
||||
|
||||
astman_send_list_complete_start(s, m, "ResourceListDetailComplete", num);
|
||||
astman_send_list_complete_start(s, m, "ResourceListDetailComplete", ami.count);
|
||||
astman_send_list_complete_end(s);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user