Browse Source

MT#55283 use typed GQueue

Change-Id: Iea5a5e988ea23a17a5b2da5f02cd972afae2db87
pull/1910/head
Richard Fuchs 10 months ago
parent
commit
347c21fc7e
5 changed files with 19 additions and 19 deletions
  1. +1
    -1
      daemon/cli.c
  2. +1
    -1
      daemon/graphite.c
  3. +15
    -15
      daemon/media_socket.c
  4. +1
    -1
      daemon/statistics.c
  5. +1
    -1
      include/media_socket.h

+ 1
- 1
daemon/cli.c View File

@ -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) { 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; struct local_intf *lif = l->data;
// only show first-order interface entries: socket families must match // only show first-order interface entries: socket families must match
if (lif->logical->preferred_family != lif->spec->local_address.addr.family) if (lif->logical->preferred_family != lif->spec->local_address.addr.family)


+ 1
- 1
daemon/graphite.c View File

@ -172,7 +172,7 @@ GString *print_graphite_data(void) {
GPF("timeout_sess "UINT64F, atomic64_get_na(&rtpe_stats_graphite_diff.timeout_sess)); 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)); 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; struct local_intf *lif = l->data;
// only show first-order interface entries: socket families must match // only show first-order interface entries: socket families must match
if (lif->logical->preferred_family != lif->spec->local_address.addr.family) if (lif->logical->preferred_family != lif->spec->local_address.addr.family)


+ 15
- 15
daemon/media_socket.c View File

@ -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); 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, TYPED_GHASHTABLE(local_intf_ht, struct intf_address, local_intf_list, __addr_type_hash, __addr_type_eq,
NULL, NULL) 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 intf_spec_ht __intf_spec_addr_type_hash;
static local_intf_ht __local_intf_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) 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; 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)) { if (G_UNLIKELY(!name || !name->s)) {
// trivial case: no interface given. just pick one suitable for the address family. // trivial case: no interface given. just pick one suitable for the address family.
// always used for legacy TCP and UDP protocols. // always used for legacy TCP and UDP protocols.
GQueue *q = NULL;
logical_intf_q *q = NULL;
if (fam) if (fam)
q = __interface_list_for_family(fam); q = __interface_list_for_family(fam);
if (!q) { 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"); static str legacy_rr_str = STR_CONST("round-robin-calls");
__add_intf_rr_1(lif, &legacy_rr_str, fam); __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]; return &__preferred_lists_for_family[fam->idx];
} }
// called during single-threaded startup only // called during single-threaded startup only
static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool create) { static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool create) {
struct logical_intf *lif; struct logical_intf *lif;
GQueue *q;
logical_intf_q *q;
struct local_intf *ifc; struct local_intf *ifc;
struct intf_spec *spec; 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); t_hash_table_insert(__logical_intf_name_family_hash, key, lif);
if (ifa->local_address.addr.family == fam) { if (ifa->local_address.addr.family == fam) {
q = __interface_list_for_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); __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->logical = lif;
ifc->stats = bufferpool_alloc0(shm_bufferpool, sizeof(*ifc->stats)); 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(&spec->local_address, ifc);
__insert_local_intf_addr_type(&ifc->advertised_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(); __local_intf_addr_type_hash = local_intf_ht_new();
for (i = 0; i < G_N_ELEMENTS(__preferred_lists_for_family); i++) 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 */ /* build primary lists first */
for (__auto_type l = interfaces->head; l; l = l->next) { 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) { void interfaces_free(void) {
struct local_intf *ifc; 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); free(ifc->ice_foundation.s);
bufferpool_unref(ifc->stats); bufferpool_unref(ifc->stats);
g_free(ifc); g_free(ifc);
@ -3277,9 +3277,9 @@ void interfaces_free(void) {
t_hash_table_destroy(__logical_intf_name_family_rr_hash); t_hash_table_destroy(__logical_intf_name_family_rr_hash);
for (int i = 0; i < G_N_ELEMENTS(__preferred_lists_for_family); i++) { 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_hash_table_destroy(lif->rr_specs);
t_queue_clear(&lif->list); t_queue_clear(&lif->list);
g_slice_free1(sizeof(*lif), lif); g_slice_free1(sizeof(*lif), lif);


+ 1
- 1
daemon/statistics.c View File

@ -654,7 +654,7 @@ stats_metric_q *statistics_gather_metrics(struct interface_sampled_rate_stats *i
HEADER("interfaces", NULL); HEADER("interfaces", NULL);
HEADER("[", 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; struct local_intf *lif = l->data;
// only show first-order interface entries: socket families must match // only show first-order interface entries: socket families must match
if (lif->logical->preferred_family != lif->spec->local_address.addr.family) if (lif->logical->preferred_family != lif->spec->local_address.addr.family)


+ 1
- 1
include/media_socket.h View File

@ -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; extern __thread struct bufferpool *media_bufferpool;


Loading…
Cancel
Save