Browse Source

MT#55283 use typed GQueue for endpoint_maps

Change-Id: Ia8dca8396dfb36bfed318fa7957cbb0f46fdcfd9
pull/1776/head
Richard Fuchs 2 years ago
parent
commit
46a5998fa6
3 changed files with 15 additions and 13 deletions
  1. +6
    -6
      daemon/call.c
  2. +6
    -5
      daemon/redis.c
  3. +3
    -2
      include/call.h

+ 6
- 6
daemon/call.c View File

@ -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, const struct endpoint *ep, const sdp_ng_flags *flags, bool always_reuse,
unsigned int want_interfaces) 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; struct endpoint_map *em = l->data;
if (em->logical_intf != media->logical_intf) if (em->logical_intf != media->logical_intf)
continue; continue;
@ -737,7 +737,7 @@ static struct endpoint_map *__latch_endpoint_map(struct call_media *media)
return NULL; return NULL;
stream_fd *matcher = first_ps->sfds.head->data; 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; struct endpoint_map *em = l->data;
if (!em->intf_sfds.length) if (!em->intf_sfds.length)
continue; continue;
@ -778,7 +778,7 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne
} }
else { else {
__C_DBG("allocating new %sendpoint map", ep ? "" : "wildcard "); __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) if (ep)
em->endpoint = *ep; em->endpoint = *ep;
else else
@ -786,7 +786,7 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne
em->logical_intf = media->logical_intf; em->logical_intf = media->logical_intf;
em->num_ports = num_ports; em->num_ports = num_ports;
t_queue_init(&em->intf_sfds); 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) 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_in);
crypto_params_sdes_queue_clear(&md->sdes_out); crypto_params_sdes_queue_clear(&md->sdes_out);
t_queue_clear(&md->streams); t_queue_clear(&md->streams);
g_queue_clear(&md->endpoint_maps);
t_queue_clear(&md->endpoint_maps);
codec_store_cleanup(&md->codecs); codec_store_cleanup(&md->codecs);
codec_handlers_free(md); codec_handlers_free(md);
codec_handler_free(&md->t38_handler); codec_handler_free(&md->t38_handler);
@ -3904,7 +3904,7 @@ static void __call_free(void *p) {
} }
while (c->endpoint_maps.head) { 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); t_queue_clear_full(&em->intf_sfds, free_sfd_intf_list);
g_slice_free1(sizeof(*em), em); g_slice_free1(sizeof(*em), em);


+ 6
- 5
daemon/redis.c View File

@ -41,6 +41,7 @@ typedef union {
medias_arr *ma; medias_arr *ma;
sfd_intf_list_q *siq; sfd_intf_list_q *siq;
packet_stream_q *psq; packet_stream_q *psq;
endpoint_map_q *emq;
} callback_arg_t __attribute__ ((__transparent_union__)); } 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]; rh = &maps->rh[i];
/* from call.c:__get_endpoint_map() */ /* 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); t_queue_init(&em->intf_sfds);
em->wildcard = redis_hash_get_bool_flag(rh, "wildcard"); 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_streams","%u", t_queue_get_length(&c->streams));
JSON_SET_SIMPLE("num_medias","%u", g_queue_get_length(&c->medias)); 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_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("ml_deleted","%ld", (long int) c->ml_deleted);
JSON_SET_SIMPLE_CSTR("created_from", c->created_from); JSON_SET_SIMPLE_CSTR("created_from", c->created_from);
JSON_SET_SIMPLE_CSTR("created_from_addr", sockaddr_print_buf(&c->created_from_addr)); 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); snprintf(tmp, sizeof(tmp), "maps-%u", media->unique_id);
json_builder_set_member_name(builder, tmp); json_builder_set_member_name(builder, tmp);
json_builder_begin_array(builder); 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; struct endpoint_map *ep = m->data;
JSON_ADD_STRING("%u", ep->unique_id); JSON_ADD_STRING("%u", ep->unique_id);
} }
@ -2636,7 +2637,7 @@ char* redis_encode_json(call_t *c) {
json_builder_end_array(builder); 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; struct endpoint_map *ep = l->data;
snprintf(tmp, sizeof(tmp), "map-%u", ep->unique_id); 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 } // --- for c->endpoint_maps.head
// -- we do it again here since the jsonbuilder is linear straight forward // -- 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; struct endpoint_map *ep = l->data;
snprintf(tmp, sizeof(tmp), "map_sfds-%u", ep->unique_id); snprintf(tmp, sizeof(tmp), "map_sfds-%u", ep->unique_id);


+ 3
- 2
include/call.h View File

@ -312,6 +312,7 @@ struct codec_store {
strip_full:1; // set by codec_store_strip strip_full:1; // set by codec_store_strip
}; };
TYPED_GQUEUE(endpoint_map, struct endpoint_map)
struct stream_params { struct stream_params {
unsigned int index; /* starting with 1 */ unsigned int index; /* starting with 1 */
@ -460,7 +461,7 @@ struct call_media {
str tls_id; str tls_id;
packet_stream_q streams; /* normally RTP + RTCP */ packet_stream_q streams; /* normally RTP + RTCP */
GQueue endpoint_maps;
endpoint_map_q endpoint_maps;
struct codec_store codecs; struct codec_store codecs;
str_q sdp_attributes; /* str_sprintf() */ str_q sdp_attributes; /* str_sprintf() */
@ -676,7 +677,7 @@ struct call {
labels_ht labels; labels_ht labels;
packet_stream_q streams; packet_stream_q streams;
stream_fd_q stream_fds; /* stream_fd */ stream_fd_q stream_fds; /* stream_fd */
GQueue endpoint_maps;
endpoint_map_q endpoint_maps;
struct dtls_cert *dtls_cert; /* for outgoing */ struct dtls_cert *dtls_cert; /* for outgoing */
struct mqtt_timer *mqtt_timer; struct mqtt_timer *mqtt_timer;


Loading…
Cancel
Save