Commit 389da431 authored by Justin Kim's avatar Justin Kim
Browse files

srtserversink: Add mutex to protect client list

parent fed6294c
......@@ -160,6 +160,7 @@ gst_srt_server_sink_get_property (GObject * object,
{
GList *item;
g_mutex_lock (&priv->mutex);
for (item = priv->clients; item; item = item->next) {
SRTClient *client = item->data;
GValue tmp = G_VALUE_INIT;
......@@ -169,6 +170,7 @@ gst_srt_server_sink_get_property (GObject * object,
client->sock));
gst_value_array_append_and_take_value (value, &tmp);
}
g_mutex_unlock (&priv->mutex);
break;
}
case PROP_LATENCY:
......@@ -256,7 +258,10 @@ idle_listen_callback (gpointer data)
client->sockaddr = g_socket_address_new_from_native (&sa, sa_len);
g_mutex_lock (&priv->mutex);
priv->clients = g_list_append (priv->clients, client);
g_mutex_unlock (&priv->mutex);
g_signal_emit (self, signals[SIG_CLIENT_ADDED], 0, client->sock,
client->sockaddr);
GST_DEBUG_OBJECT (self, "client added");
......@@ -414,6 +419,7 @@ gst_srt_server_sink_send_buffer (GstSRTBaseSink * sink,
GstSRTServerSinkPrivate *priv = GST_SRT_SERVER_SINK_GET_PRIVATE (self);
GList *clients = priv->clients;
g_mutex_lock (&priv->mutex);
while (clients != NULL) {
SRTClient *client = clients->data;
clients = clients->next;
......@@ -428,6 +434,7 @@ gst_srt_server_sink_send_buffer (GstSRTBaseSink * sink,
srt_client_free (client);
}
}
g_mutex_unlock (&priv->mutex);
return TRUE;
}
......@@ -440,8 +447,10 @@ gst_srt_server_sink_stop (GstBaseSink * sink)
gboolean ret = TRUE;
GST_DEBUG_OBJECT (self, "closing client sockets");
g_mutex_lock (&priv->mutex);
g_list_foreach (priv->clients, (GFunc) srt_emit_client_removed, self);
g_list_free_full (priv->clients, (GDestroyNotify) srt_client_free);
g_mutex_unlock (&priv->mutex);
GST_DEBUG_OBJECT (self, "closing SRT connection");
srt_epoll_remove_usock (priv->poll_id, priv->sock);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment