From 46a5998fa66f39d731703e9423d843fc957484e5 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 12 Dec 2023 14:17:46 -0500 Subject: [PATCH] MT#55283 use typed GQueue for endpoint_maps Change-Id: Ia8dca8396dfb36bfed318fa7957cbb0f46fdcfd9 --- daemon/call.c | 12 ++++++------ daemon/redis.c | 11 ++++++----- include/call.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index f8758604e..c19d9723c 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -675,7 +675,7 @@ static struct endpoint_map *__hunt_endpoint_map(struct call_media *media, unsign const struct endpoint *ep, const sdp_ng_flags *flags, bool always_reuse, unsigned int want_interfaces) { - for (GList *l = media->endpoint_maps.tail; l; l = l->prev) { + for (__auto_type l = media->endpoint_maps.tail; l; l = l->prev) { struct endpoint_map *em = l->data; if (em->logical_intf != media->logical_intf) continue; @@ -737,7 +737,7 @@ static struct endpoint_map *__latch_endpoint_map(struct call_media *media) return NULL; stream_fd *matcher = first_ps->sfds.head->data; - for (GList *l = media->endpoint_maps.tail; l; l = l->prev) { + for (__auto_type l = media->endpoint_maps.tail; l; l = l->prev) { struct endpoint_map *em = l->data; if (!em->intf_sfds.length) continue; @@ -778,7 +778,7 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne } else { __C_DBG("allocating new %sendpoint map", ep ? "" : "wildcard "); - em = uid_slice_alloc0(em, &media->call->endpoint_maps); + em = uid_slice_alloc0(em, &media->call->endpoint_maps.q); if (ep) em->endpoint = *ep; else @@ -786,7 +786,7 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne em->logical_intf = media->logical_intf; em->num_ports = num_ports; t_queue_init(&em->intf_sfds); - g_queue_push_tail(&media->endpoint_maps, em); + t_queue_push_tail(&media->endpoint_maps, em); } if (num_ports > 16) @@ -3849,7 +3849,7 @@ void call_media_free(struct call_media **mdp) { crypto_params_sdes_queue_clear(&md->sdes_in); crypto_params_sdes_queue_clear(&md->sdes_out); t_queue_clear(&md->streams); - g_queue_clear(&md->endpoint_maps); + t_queue_clear(&md->endpoint_maps); codec_store_cleanup(&md->codecs); codec_handlers_free(md); codec_handler_free(&md->t38_handler); @@ -3904,7 +3904,7 @@ static void __call_free(void *p) { } while (c->endpoint_maps.head) { - em = g_queue_pop_head(&c->endpoint_maps); + em = t_queue_pop_head(&c->endpoint_maps); t_queue_clear_full(&em->intf_sfds, free_sfd_intf_list); g_slice_free1(sizeof(*em), em); diff --git a/daemon/redis.c b/daemon/redis.c index dc8a8e970..0f31a9eef 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -41,6 +41,7 @@ typedef union { medias_arr *ma; sfd_intf_list_q *siq; packet_stream_q *psq; + endpoint_map_q *emq; } callback_arg_t __attribute__ ((__transparent_union__)); @@ -1621,7 +1622,7 @@ static int redis_maps(call_t *c, struct redis_list *maps) { rh = &maps->rh[i]; /* from call.c:__get_endpoint_map() */ - em = uid_slice_alloc0(em, &c->endpoint_maps); + em = uid_slice_alloc0(em, &c->endpoint_maps.q); t_queue_init(&em->intf_sfds); em->wildcard = redis_hash_get_bool_flag(rh, "wildcard"); @@ -2355,7 +2356,7 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE("num_streams","%u", t_queue_get_length(&c->streams)); JSON_SET_SIMPLE("num_medias","%u", g_queue_get_length(&c->medias)); JSON_SET_SIMPLE("num_tags","%u", g_queue_get_length(&c->monologues)); - JSON_SET_SIMPLE("num_maps","%u", g_queue_get_length(&c->endpoint_maps)); + JSON_SET_SIMPLE("num_maps","%u", t_queue_get_length(&c->endpoint_maps)); JSON_SET_SIMPLE("ml_deleted","%ld", (long int) c->ml_deleted); JSON_SET_SIMPLE_CSTR("created_from", c->created_from); JSON_SET_SIMPLE_CSTR("created_from_addr", sockaddr_print_buf(&c->created_from_addr)); @@ -2617,7 +2618,7 @@ char* redis_encode_json(call_t *c) { snprintf(tmp, sizeof(tmp), "maps-%u", media->unique_id); json_builder_set_member_name(builder, tmp); json_builder_begin_array(builder); - for (GList *m = media->endpoint_maps.head; m; m = m->next) { + for (__auto_type m = media->endpoint_maps.head; m; m = m->next) { struct endpoint_map *ep = m->data; JSON_ADD_STRING("%u", ep->unique_id); } @@ -2636,7 +2637,7 @@ char* redis_encode_json(call_t *c) { json_builder_end_array(builder); } - for (GList *l = c->endpoint_maps.head; l; l = l->next) { + for (__auto_type l = c->endpoint_maps.head; l; l = l->next) { struct endpoint_map *ep = l->data; snprintf(tmp, sizeof(tmp), "map-%u", ep->unique_id); @@ -2656,7 +2657,7 @@ char* redis_encode_json(call_t *c) { } // --- for c->endpoint_maps.head // -- we do it again here since the jsonbuilder is linear straight forward - for (GList *l = c->endpoint_maps.head; l; l = l->next) { + for (__auto_type l = c->endpoint_maps.head; l; l = l->next) { struct endpoint_map *ep = l->data; snprintf(tmp, sizeof(tmp), "map_sfds-%u", ep->unique_id); diff --git a/include/call.h b/include/call.h index d4b248c26..68feb2a03 100644 --- a/include/call.h +++ b/include/call.h @@ -312,6 +312,7 @@ struct codec_store { strip_full:1; // set by codec_store_strip }; +TYPED_GQUEUE(endpoint_map, struct endpoint_map) struct stream_params { unsigned int index; /* starting with 1 */ @@ -460,7 +461,7 @@ struct call_media { str tls_id; packet_stream_q streams; /* normally RTP + RTCP */ - GQueue endpoint_maps; + endpoint_map_q endpoint_maps; struct codec_store codecs; str_q sdp_attributes; /* str_sprintf() */ @@ -676,7 +677,7 @@ struct call { labels_ht labels; packet_stream_q streams; stream_fd_q stream_fds; /* stream_fd */ - GQueue endpoint_maps; + endpoint_map_q endpoint_maps; struct dtls_cert *dtls_cert; /* for outgoing */ struct mqtt_timer *mqtt_timer;