Browse Source

MT#55283 specialise struct intf_list

There's two flavours of this struct being in use, even though the
structs' signatures are the same. One contains socket_t objects, the
other contains stream_fd objects. Separate them out and be explicit
about which is which.

Change-Id: I5ef1d154cc442528149f69be2e6a02625a6c650d
pull/1776/head
Richard Fuchs 2 years ago
parent
commit
3114510c12
5 changed files with 22 additions and 19 deletions
  1. +7
    -7
      daemon/call.c
  2. +4
    -4
      daemon/media_socket.c
  3. +2
    -2
      daemon/redis.c
  4. +1
    -1
      include/call.h
  5. +8
    -5
      include/media_socket.h

+ 7
- 7
daemon/call.c View File

@ -668,8 +668,8 @@ static int __media_want_interfaces(struct call_media *media) {
}
static void __endpoint_map_truncate(struct endpoint_map *em, unsigned int num_intfs) {
while (em->intf_sfds.length > num_intfs) {
struct intf_list *il = g_queue_pop_tail(&em->intf_sfds);
free_release_intf_list(il);
struct sfd_intf_list *il = g_queue_pop_tail(&em->intf_sfds);
free_sfd_intf_list(il);
}
}
static struct endpoint_map *__hunt_endpoint_map(struct call_media *media, unsigned int num_ports,
@ -683,7 +683,7 @@ static struct endpoint_map *__hunt_endpoint_map(struct call_media *media, unsign
// any of our sockets shut down?
for (GList *k = em->intf_sfds.head; k; k = k->next) {
struct intf_list *il = k->data;
struct sfd_intf_list *il = k->data;
for (GList *j = il->list.head; j; j = j->next) {
struct stream_fd *sfd = j->data;
if (sfd->socket.fd == -1)
@ -742,7 +742,7 @@ static struct endpoint_map *__latch_endpoint_map(struct call_media *media)
struct endpoint_map *em = l->data;
if (!em->intf_sfds.length)
continue;
struct intf_list *em_il = em->intf_sfds.head->data;
struct sfd_intf_list *em_il = em->intf_sfds.head->data;
if (!em_il->list.length)
continue;
struct stream_fd *first = em_il->list.head->data;
@ -797,12 +797,12 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne
__C_DBG("allocating stream_fds for %u ports", num_ports);
struct intf_list *il;
struct socket_intf_list *il;
while ((il = g_queue_pop_head(&intf_sockets))) {
if (il->list.length != num_ports)
goto next_il;
struct intf_list *em_il = g_slice_alloc0(sizeof(*em_il));
struct sfd_intf_list *em_il = g_slice_alloc0(sizeof(*em_il));
em_il->local_intf = il->local_intf;
g_queue_push_tail(&em->intf_sfds, em_il);
@ -839,7 +839,7 @@ static void __assign_stream_fds(struct call_media *media, GQueue *intf_sfds) {
struct stream_fd *intf_sfd = NULL;
for (GList *l = intf_sfds->head; l; l = l->next) {
struct intf_list *il = l->data;
struct sfd_intf_list *il = l->data;
struct stream_fd *sfd = g_queue_peek_nth(&il->list, ps->component - 1);
if (!sfd)


+ 4
- 4
daemon/media_socket.c View File

@ -1213,7 +1213,7 @@ fail:
int get_consecutive_ports(GQueue *out, unsigned int num_ports, unsigned int num_intfs, struct call_media *media)
{
GList *l;
struct intf_list *il;
struct socket_intf_list *il;
struct local_intf *loc;
const struct logical_intf *log = media->logical_intf;
const str *label = &media->call->callid; /* call's callid */
@ -1261,18 +1261,18 @@ error_ports:
return -1;
}
void free_socket_intf_list(struct intf_list *il) {
void free_socket_intf_list(struct socket_intf_list *il) {
socket_t *sock;
while ((sock = g_queue_pop_head(&il->list)))
free_port(sock, il->local_intf->spec);
g_slice_free1(sizeof(*il), il);
}
void free_intf_list(struct intf_list *il) {
void free_intf_list(struct socket_intf_list *il) {
g_queue_clear(&il->list);
g_slice_free1(sizeof(*il), il);
}
void free_release_intf_list(struct intf_list *il) {
void free_sfd_intf_list(struct sfd_intf_list *il) {
g_queue_clear_full(&il->list, (GDestroyNotify) stream_fd_release);
g_slice_free1(sizeof(*il), il);
}


+ 2
- 2
daemon/redis.c View File

@ -1865,7 +1865,7 @@ static int json_link_medias(struct call *c, struct redis_list *medias,
static int rbl_cb_intf_sfds(str *s, callback_arg_t qp, struct redis_list *list, void *ptr) {
GQueue *q = qp.q;
int i;
struct intf_list *il;
struct sfd_intf_list *il;
struct endpoint_map *em;
void *sfd;
@ -2662,7 +2662,7 @@ char* redis_encode_json(struct call *c) {
json_builder_set_member_name(builder, tmp);
json_builder_begin_array(builder);
for (GList *m = ep->intf_sfds.head; m; m = m->next) {
struct intf_list *il = m->data;
struct sfd_intf_list *il = m->data;
JSON_ADD_STRING("loc-%u", il->local_intf->unique_id);
for (GList *n = il->list.head; n; n = n->next) {
struct stream_fd *sfd = n->data;


+ 1
- 1
include/call.h View File

@ -347,7 +347,7 @@ struct endpoint_map {
struct endpoint endpoint;
unsigned int num_ports;
const struct logical_intf *logical_intf;
GQueue intf_sfds; /* list of struct intf_list - contains stream_fd list */
GQueue intf_sfds; /* list of struct sfd_intf_list - contains stream_fd list */
unsigned int wildcard:1;
};


+ 8
- 5
include/media_socket.h View File

@ -191,7 +191,11 @@ struct local_intf {
struct interface_stats_block stats;
};
struct intf_list {
struct socket_intf_list {
struct local_intf *local_intf;
GQueue list;
};
struct sfd_intf_list {
struct local_intf *local_intf;
GQueue list;
};
@ -306,10 +310,9 @@ void stream_fd_release(struct stream_fd *);
enum thread_looper_action release_closed_sockets(void);
void append_thread_lpr_to_glob_lpr(void);
void free_intf_list(struct intf_list *il);
void free_release_intf_list(struct intf_list *il);
void free_release_intf_list(struct intf_list *il);
void free_socket_intf_list(struct intf_list *il);
void free_intf_list(struct socket_intf_list *il);
void free_sfd_intf_list(struct sfd_intf_list *il);
void free_socket_intf_list(struct socket_intf_list *il);
INLINE int open_intf_socket(socket_t *r, unsigned int port, const struct local_intf *lif) {
return open_socket(r, SOCK_DGRAM, port, &lif->spec->local_address.addr);


Loading…
Cancel
Save