Browse Source

MT#55283 use typed queue for local_intf

Change-Id: Id7bf3804ab029bdf60d010b05e057bb7851645cd
pull/1910/head
Richard Fuchs 10 months ago
parent
commit
02bccee56b
3 changed files with 10 additions and 10 deletions
  1. +6
    -8
      daemon/media_socket.c
  2. +1
    -1
      daemon/redis.c
  3. +3
    -1
      include/media_socket.h

+ 6
- 8
daemon/media_socket.c View File

@ -496,9 +496,8 @@ static int has_free_ports_log_all(struct logical_intf *log, unsigned int num_por
} }
struct local_intf *loc; struct local_intf *loc;
GList *l;
for (l = log->list.head; l; l = l->next) {
for (__auto_type l = log->list.head; l; l = l->next) {
loc = l->data; loc = l->data;
if (!has_free_ports_loc(loc, num_ports)) { if (!has_free_ports_loc(loc, num_ports)) {
@ -804,7 +803,7 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool
return; return;
lif = g_slice_alloc0(sizeof(*lif)); lif = g_slice_alloc0(sizeof(*lif));
g_queue_init(&lif->list);
t_queue_init(&lif->list);
lif->name = ifa->name; lif->name = ifa->name;
lif->name_base = ifa->name_base; lif->name_base = ifa->name_base;
lif->preferred_family = fam; lif->preferred_family = fam;
@ -849,7 +848,7 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool
} }
} }
ifc = uid_slice_alloc0(ifc, &lif->list);
ifc = uid_slice_alloc0(ifc, &lif->list.q);
ice_foundation(&ifc->ice_foundation); ice_foundation(&ifc->ice_foundation);
ifc->advertised_address = ifa->advertised_address; ifc->advertised_address = ifa->advertised_address;
ifc->spec = spec; ifc->spec = spec;
@ -925,7 +924,7 @@ void interfaces_exclude_port(unsigned int port) {
} }
struct local_intf *get_interface_address(const struct logical_intf *lif, sockfamily_t *fam) { struct local_intf *get_interface_address(const struct logical_intf *lif, sockfamily_t *fam) {
const GQueue *q;
const local_intf_q *q;
if (!fam) if (!fam)
return NULL; return NULL;
@ -1262,7 +1261,6 @@ fail:
/* puts a list of "struct intf_list" into "out", containing socket_t list */ /* puts a list of "struct intf_list" into "out", containing socket_t list */
int get_consecutive_ports(socket_intf_list_q *out, unsigned int num_ports, unsigned int num_intfs, struct call_media *media) int get_consecutive_ports(socket_intf_list_q *out, unsigned int num_ports, unsigned int num_intfs, struct call_media *media)
{ {
GList *l;
struct socket_intf_list *il; struct socket_intf_list *il;
struct local_intf *loc; struct local_intf *loc;
const struct logical_intf *log = media->logical_intf; const struct logical_intf *log = media->logical_intf;
@ -1279,7 +1277,7 @@ int get_consecutive_ports(socket_intf_list_q *out, unsigned int num_ports, unsig
ilog(LOG_DEBUG, ""); ilog(LOG_DEBUG, "");
*/ */
for (l = log->list.head; l; l = l->next) {
for (__auto_type l = log->list.head; l; l = l->next) {
if (out->length >= num_intfs) if (out->length >= num_intfs)
break; break;
@ -3274,7 +3272,7 @@ void interfaces_free(void) {
struct logical_intf *lif; struct logical_intf *lif;
while ((lif = g_queue_pop_head(q))) { while ((lif = g_queue_pop_head(q))) {
g_hash_table_destroy(lif->rr_specs); g_hash_table_destroy(lif->rr_specs);
g_queue_clear(&lif->list);
t_queue_clear(&lif->list);
g_slice_free1(sizeof(*lif), lif); g_slice_free1(sizeof(*lif), lif);
} }
} }


+ 1
- 1
daemon/redis.c View File

@ -1416,7 +1416,7 @@ static int redis_sfds(call_t *c, struct redis_list *sfds) {
if (!lif) if (!lif)
goto err; goto err;
err = "not enough local interfaces"; err = "not enough local interfaces";
loc = g_queue_peek_nth(&lif->list, loc_uid);
loc = t_queue_peek_nth(&lif->list, loc_uid);
if (!loc) if (!loc)
goto err; goto err;


+ 3
- 1
include/media_socket.h View File

@ -74,10 +74,12 @@ struct streamhandler {
TYPED_GQUEUE(local_intf, struct local_intf)
struct logical_intf { struct logical_intf {
str name; str name;
sockfamily_t *preferred_family; sockfamily_t *preferred_family;
GQueue list; /* struct local_intf */
local_intf_q list;
GHashTable *rr_specs; GHashTable *rr_specs;
str name_base; // if name is "foo:bar", this is "foo" str name_base; // if name is "foo:bar", this is "foo"
}; };


Loading…
Cancel
Save