Browse Source

MT#55283 use intrusive list

Change-Id: I53c561dcc781f5cbd367ccb0df7b6900241f5e24
pull/2025/head
Richard Fuchs 2 months ago
parent
commit
914f6dfa1a
3 changed files with 14 additions and 10 deletions
  1. +4
    -3
      daemon/call.c
  2. +7
    -4
      daemon/media_socket.c
  3. +3
    -3
      include/media_socket.h

+ 4
- 3
daemon/call.c View File

@ -3716,12 +3716,13 @@ static bool media_open_ports(struct call_media *media) {
__C_DBG("allocating stream_fds for %u ports", em->num_ports);
MEDIA_CLEAR(media, PUBLIC);
socket_port_q q = TYPED_GQUEUE_INIT; // XXX use some sort of intrusive list for this
socket_port_q q = TYPED_GQUEUE_INIT;
if (!get_consecutive_ports(&q, em->num_ports, em_il->local_intf, label))
return false;
struct socket_port_link *spl;
while ((spl = t_queue_pop_head(&q))) {
socket_port_list *spll;
while ((spll = t_queue_pop_head_link(&q))) {
__auto_type spl = spll->data;
set_tos(&spl->socket, media->call->tos);
if (media->call->cpu_affinity >= 0) {
if (socket_cpu_affinity(&spl->socket, media->call->cpu_affinity))


+ 7
- 4
daemon/media_socket.c View File

@ -801,7 +801,8 @@ static void release_reserved_port(struct port_pool *pp, ports_q *list, unsigned
static void release_reserved_ports(socket_port_q *ports) {
while (ports->length) {
__auto_type p = t_queue_pop_head(ports);
__auto_type pl = t_queue_pop_head_link(ports);
__auto_type p = pl->data;
if (p->links.length)
release_reserved_port(p->pp, &p->links, GPOINTER_TO_UINT(p->links.head->data));
g_free(p);
@ -1257,7 +1258,7 @@ static bool __get_consecutive_ports(socket_port_q *out, unsigned int num_ports,
{
unsigned int allocation_attempts = 0, available_ports = 0, additional_port = 0, port = 0;
struct port_pool * pp = &spec->port_pool; /* port pool for a given local interface */
struct port_pool *pp = &spec->port_pool; /* port pool for a given local interface */
ports_q *free_ports_q;
if (num_ports == 0) {
@ -1330,7 +1331,8 @@ new_cycle:
__auto_type splp = g_new(struct socket_port_link, 1);
*splp = spl;
t_queue_push_tail(out, splp);
splp->link.data = splp;
t_queue_push_tail_link(out, &splp->link);
/* find additional ports, usually it's only RTCP */
additional_port = port;
@ -1352,7 +1354,8 @@ new_cycle:
/* track for which additional ports, we have to open sockets */
splp = g_new(struct socket_port_link, 1);
*splp = spl;
t_queue_push_tail(out, splp);
splp->link.data = splp;
t_queue_push_tail_link(out, &splp->link);
}
ilog(LOG_DEBUG, "Trying to bind the socket for RTP/RTCP ports (allocation attempt = '%d')",


+ 3
- 3
include/media_socket.h View File

@ -93,11 +93,13 @@ struct logical_intf {
typedef void port_t;
TYPED_GQUEUE(ports, port_t)
TYPED_GQUEUE(socket_port, struct socket_port_link)
struct socket_port_link {
socket_t socket;
socket_t socket; // must be first
ports_q links;
struct port_pool *pp;
socket_port_list link;
};
TYPED_GQUEUE(port_pool, struct port_pool)
@ -177,8 +179,6 @@ void interface_sampled_rate_stats_destroy(struct interface_sampled_rate_stats *)
struct interface_stats_block *interface_sampled_rate_stats_get(struct interface_sampled_rate_stats *s,
struct local_intf *lif, int64_t *time_diff_us);
TYPED_GQUEUE(socket_port, struct socket_port_link)
struct local_intf {
struct intf_spec *spec;
struct intf_address advertised_address;


Loading…
Cancel
Save