From 347c21fc7e5c5c3aeb7ce723a1b1c1ac44de6ada Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 6 Feb 2025 12:07:14 -0400 Subject: [PATCH] MT#55283 use typed GQueue Change-Id: Iea5a5e988ea23a17a5b2da5f02cd972afae2db87 --- daemon/cli.c | 2 +- daemon/graphite.c | 2 +- daemon/media_socket.c | 30 +++++++++++++++--------------- daemon/statistics.c | 2 +- include/media_socket.h | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/daemon/cli.c b/daemon/cli.c index 519ad2867..90f7ec5d0 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -1754,7 +1754,7 @@ static void cli_incoming_set_rediscmdtimeout(str *instr, struct cli_writer *cw, } static void cli_incoming_list_interfaces(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { - for (GList *l = all_local_interfaces.head; l; l = l->next) { + for (__auto_type l = all_local_interfaces.head; l; l = l->next) { struct local_intf *lif = l->data; // only show first-order interface entries: socket families must match if (lif->logical->preferred_family != lif->spec->local_address.addr.family) diff --git a/daemon/graphite.c b/daemon/graphite.c index 6f9eab8d1..f5293bca7 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -172,7 +172,7 @@ GString *print_graphite_data(void) { GPF("timeout_sess "UINT64F, atomic64_get_na(&rtpe_stats_graphite_diff.timeout_sess)); GPF("reject_sess "UINT64F, atomic64_get_na(&rtpe_stats_graphite_diff.rejected_sess)); - for (GList *l = all_local_interfaces.head; l; l = l->next) { + for (__auto_type l = all_local_interfaces.head; l; l = l->next) { struct local_intf *lif = l->data; // only show first-order interface entries: socket families must match if (lif->logical->preferred_family != lif->spec->local_address.addr.family) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index c20362547..c3dc6afac 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -418,7 +418,7 @@ static const struct rtpengine_srtp __res_null = { -static GQueue *__interface_list_for_family(sockfamily_t *fam); +static logical_intf_q *__interface_list_for_family(sockfamily_t *fam); static unsigned int __name_family_hash(const struct intf_key *p); @@ -435,13 +435,13 @@ TYPED_GHASHTABLE(intf_spec_ht, struct intf_address, struct intf_spec, __addr_typ TYPED_GHASHTABLE(local_intf_ht, struct intf_address, local_intf_list, __addr_type_hash, __addr_type_eq, NULL, NULL) -static intf_lookup __logical_intf_name_family_hash; // name + family -> struct logical_intf -static intf_rr_lookup __logical_intf_name_family_rr_hash; // name + family -> struct intf_rr +static intf_lookup __logical_intf_name_family_hash; +static intf_rr_lookup __logical_intf_name_family_rr_hash; static intf_spec_ht __intf_spec_addr_type_hash; static local_intf_ht __local_intf_addr_type_hash; -static GQueue __preferred_lists_for_family[__SF_LAST]; +static logical_intf_q __preferred_lists_for_family[__SF_LAST]; -GQueue all_local_interfaces = G_QUEUE_INIT; +local_intf_q all_local_interfaces = TYPED_GQUEUE_INIT; TYPED_GHASHTABLE(local_sockets_ht, endpoint_t, stream_fd, endpoint_hash, endpoint_eq, NULL, stream_fd_put) static rwlock_t local_media_socket_endpoints_lock = RWLOCK_STATIC_INIT; @@ -561,7 +561,7 @@ struct logical_intf *get_logical_interface(const str *name, sockfamily_t *fam, i if (G_UNLIKELY(!name || !name->s)) { // trivial case: no interface given. just pick one suitable for the address family. // always used for legacy TCP and UDP protocols. - GQueue *q = NULL; + logical_intf_q *q = NULL; if (fam) q = __interface_list_for_family(fam); if (!q) { @@ -764,13 +764,13 @@ static void __add_intf_rr(struct logical_intf *lif, str *name_base, sockfamily_t static str legacy_rr_str = STR_CONST("round-robin-calls"); __add_intf_rr_1(lif, &legacy_rr_str, fam); } -static GQueue *__interface_list_for_family(sockfamily_t *fam) { +static logical_intf_q *__interface_list_for_family(sockfamily_t *fam) { return &__preferred_lists_for_family[fam->idx]; } // called during single-threaded startup only static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool create) { struct logical_intf *lif; - GQueue *q; + logical_intf_q *q; struct local_intf *ifc; struct intf_spec *spec; @@ -812,7 +812,7 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool t_hash_table_insert(__logical_intf_name_family_hash, key, lif); if (ifa->local_address.addr.family == fam) { q = __interface_list_for_family(fam); - g_queue_push_tail(q, lif); + t_queue_push_tail(q, lif); __add_intf_rr(lif, &ifa->name_base, fam); } } @@ -867,7 +867,7 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool ifc->logical = lif; ifc->stats = bufferpool_alloc0(shm_bufferpool, sizeof(*ifc->stats)); - g_queue_push_tail(&all_local_interfaces, ifc); + t_queue_push_tail(&all_local_interfaces, ifc); __insert_local_intf_addr_type(&spec->local_address, ifc); __insert_local_intf_addr_type(&ifc->advertised_address, ifc); @@ -886,7 +886,7 @@ void interfaces_init(intf_config_q *interfaces) { __local_intf_addr_type_hash = local_intf_ht_new(); for (i = 0; i < G_N_ELEMENTS(__preferred_lists_for_family); i++) - g_queue_init(&__preferred_lists_for_family[i]); + t_queue_init(&__preferred_lists_for_family[i]); /* build primary lists first */ for (__auto_type l = interfaces->head; l; l = l->next) { @@ -3240,7 +3240,7 @@ void play_buffered(struct jb_packet *cp) { void interfaces_free(void) { struct local_intf *ifc; - while ((ifc = g_queue_pop_head(&all_local_interfaces))) { + while ((ifc = t_queue_pop_head(&all_local_interfaces))) { free(ifc->ice_foundation.s); bufferpool_unref(ifc->stats); g_free(ifc); @@ -3277,9 +3277,9 @@ void interfaces_free(void) { t_hash_table_destroy(__logical_intf_name_family_rr_hash); for (int i = 0; i < G_N_ELEMENTS(__preferred_lists_for_family); i++) { - GQueue *q = &__preferred_lists_for_family[i]; - struct logical_intf *lif; - while ((lif = g_queue_pop_head(q))) { + logical_intf_q *q = &__preferred_lists_for_family[i]; + while (q->length) { + __auto_type lif = t_queue_pop_head(q); t_hash_table_destroy(lif->rr_specs); t_queue_clear(&lif->list); g_slice_free1(sizeof(*lif), lif); diff --git a/daemon/statistics.c b/daemon/statistics.c index 02be04f37..f8c6556d9 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -654,7 +654,7 @@ stats_metric_q *statistics_gather_metrics(struct interface_sampled_rate_stats *i HEADER("interfaces", NULL); HEADER("[", NULL); - for (GList *l = all_local_interfaces.head; l; l = l->next) { + for (__auto_type l = all_local_interfaces.head; l; l = l->next) { struct local_intf *lif = l->data; // only show first-order interface entries: socket families must match if (lif->logical->preferred_family != lif->spec->local_address.addr.family) diff --git a/include/media_socket.h b/include/media_socket.h index cfd45b030..0bbb1b5ad 100644 --- a/include/media_socket.h +++ b/include/media_socket.h @@ -275,7 +275,7 @@ struct media_packet { -extern GQueue all_local_interfaces; // read-only during runtime +extern local_intf_q all_local_interfaces; // read-only during runtime extern __thread struct bufferpool *media_bufferpool;