Browse Source

MT#55283 introduce stream_fd lock

Required to avoid races over the "kernelized" flag

Change-Id: I316cc82d57a51e8778be4562a46a262804a7197f
(cherry picked from commit 8b4219f739)
mr14.0
Richard Fuchs 22 hours ago
parent
commit
d3f27b3d75
2 changed files with 9 additions and 0 deletions
  1. +8
    -0
      daemon/media_socket.c
  2. +1
    -0
      include/media_socket.h

+ 8
- 0
daemon/media_socket.c View File

@ -1930,6 +1930,10 @@ static void kernelize(struct packet_stream *stream) {
if (!stream->selected_sfd)
goto no_kernel;
{
LOCK(&stream->selected_sfd->lock);
if (stream->selected_sfd->kernelized)
return;
@ -2006,6 +2010,8 @@ static void kernelize(struct packet_stream *stream) {
stream->kernel_time_us = rtpe_now;
stream->selected_sfd->kernelized = true;
}
return;
no_kernel_warn:
@ -3936,6 +3942,7 @@ static void stream_fd_free(stream_fd *f) {
release_port(&f->spl);
crypto_cleanup(&f->crypto);
dtls_connection_cleanup(&f->dtls);
mutex_destroy(&f->lock);
obj_put(f->call);
}
@ -3945,6 +3952,7 @@ stream_fd *stream_fd_new(struct socket_port_link *spl, call_t *call, struct loca
struct poller_item pi;
sfd = obj_alloc0(stream_fd, stream_fd_free);
mutex_init(&sfd->lock);
sfd->unique_id = t_queue_get_length(&call->stream_fds);
sfd->call = obj_get(call);
sfd->local_intf = lif;


+ 1
- 0
include/media_socket.h View File

@ -221,6 +221,7 @@ struct stream_fd {
* (plus some other wrapper functions).
*/
struct obj obj;
mutex_t lock; // for kernelized flag, nested under stream->lock
unsigned int unique_id; /* RO */
union {


Loading…
Cancel
Save