Browse Source

MT#55283 introduce socket use counter

Change-Id: I2468f4faedd195c9ea52d6ee6c99eabf37b7e73e
pull/2025/head
Richard Fuchs 2 months ago
parent
commit
4f5d013640
3 changed files with 24 additions and 3 deletions
  1. +4
    -2
      daemon/call.c
  2. +1
    -1
      daemon/media_socket.c
  3. +19
    -0
      include/media_socket.h

+ 4
- 2
daemon/call.c View File

@ -793,7 +793,7 @@ static bool __endpoint_map_truncate(struct endpoint_map *em, unsigned int num_in
__auto_type il = l->data;
while (il->list.length > num_ports) {
__auto_type p = t_queue_pop_tail(&il->list);
stream_fd_release(p);
stream_fd_dec(p);
}
}
@ -925,6 +925,7 @@ static void __assign_stream_fds(struct call_media *media, sfd_intf_list_q *intf_
}
sfd->stream = ps;
stream_fd_inc(sfd);
t_queue_push_tail(&ps->sfds, sfd);
if (ps->selected_sfd == sfd)
@ -3729,6 +3730,7 @@ static bool media_open_ports(struct call_media *media) {
}
__auto_type sfd = stream_fd_new(spl, media->call, em_il->local_intf);
t_queue_push_tail(&em_il->list, sfd); // not referenced
stream_fd_inc(sfd);
g_free(spl); // XXX eliminate this
}
}
@ -5631,7 +5633,7 @@ void monologue_destroy(struct call_monologue *monologue) {
stream_fd *sfd;
while ((sfd = t_queue_pop_head(&ps->sfds)))
stream_fd_release(sfd);
stream_fd_dec(sfd);
}
if (m->endpoint_map)
t_queue_clear_full(&m->endpoint_map->intf_sfds, free_release_sfd_intf_list);


+ 1
- 1
daemon/media_socket.c View File

@ -1396,7 +1396,7 @@ void free_sfd_intf_list(struct sfd_intf_list *il) {
g_free(il);
}
void free_release_sfd_intf_list(struct sfd_intf_list *il) {
t_queue_clear_full(&il->list, stream_fd_release);
t_queue_clear_full(&il->list, stream_fd_dec);
g_free(il);
}


+ 19
- 0
include/media_socket.h View File

@ -242,10 +242,13 @@ struct stream_fd {
int active_read_events;
struct poller *poller;
unsigned int users;
bool kernelized:1,
confirmed:1;
};
struct sink_attrs {
// cannot be bit fields because G_STRUCT_OFFSET is used on them
bool block_media;
@ -399,6 +402,22 @@ void stream_fd_release(stream_fd *);
enum thread_looper_action release_closed_sockets(void);
void append_thread_lpr_to_glob_lpr(void);
// needs upper level locking
__attribute__((nonnull(1)))
INLINE void stream_fd_inc(stream_fd *sfd) {
sfd->users++;
}
// needs upper level locking
__attribute__((nonnull(1)))
INLINE void stream_fd_dec(stream_fd *sfd) {
if (--sfd->users > 0)
return;
stream_fd_release(sfd);
}
void free_sfd_intf_list(struct sfd_intf_list *il);
void free_release_sfd_intf_list(struct sfd_intf_list *il);
void free_socket_intf_list(struct socket_intf_list *il);


Loading…
Cancel
Save