]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Fix empty `ActiveChannels` property in AMI responses.
authorSean Bright <sean@seanbright.com>
Tue, 27 May 2025 16:56:30 +0000 (12:56 -0400)
committerGeorge Joseph <gjoseph@sangoma.com>
Thu, 26 Jun 2025 18:15:05 +0000 (12:15 -0600)
The logic appears to have been reversed since it was introduced in
05cbf8df.

Resolves: #1254
(cherry picked from commit b1065e783dcdf24b2d97b3d8cf5ee9e6bdfe6959)

res/res_pjsip/pjsip_configuration.c

index c2d78dfa347280137ae7d068fc27ebe370f600ce..614e55f5b8c7183e716a792977a196826f998993 100644 (file)
@@ -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