From: Sean Bright Date: Tue, 27 May 2025 16:56:30 +0000 (-0400) Subject: res_pjsip: Fix empty `ActiveChannels` property in AMI responses. X-Git-Tag: 20.15.0-rc1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc563a11f415ea9e34705102ed4b09b2f7370cc2;p=thirdparty%2Fasterisk.git res_pjsip: Fix empty `ActiveChannels` property in AMI responses. The logic appears to have been reversed since it was introduced in 05cbf8df. Resolves: #1254 (cherry picked from commit 0f5ea4797e483dadd636c9686c69cd473924e786) --- diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index c2d78dfa34..614e55f5b8 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -1710,14 +1710,6 @@ int ast_sip_for_each_channel( return ast_sip_for_each_channel_snapshot(endpoint_snapshot, on_channel_snapshot, arg); } -static int active_channels_to_str_cb(void *object, void *arg, int flags) -{ - const struct ast_channel_snapshot *snapshot = object; - struct ast_str **buf = arg; - ast_str_append(buf, 0, "%s,", snapshot->base->name); - return 0; -} - static void active_channels_to_str(const struct ast_sip_endpoint *endpoint, struct ast_str **str) { @@ -1725,13 +1717,8 @@ static void active_channels_to_str(const struct ast_sip_endpoint *endpoint, RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup); - if (endpoint_snapshot) { - return; - } - - ast_sip_for_each_channel_snapshot(endpoint_snapshot, - active_channels_to_str_cb, str); - ast_str_truncate(*str, -1); + ast_str_append(str, 0, "%d", + endpoint_snapshot ? endpoint_snapshot->num_channels : 0); } #define AMI_DEFAULT_STR_SIZE 512