mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-13 12:51:16 +00:00
rtsp-client: make closing more thread safe
+ Take the watch lock prior to using priv->watch + Flush both the watch and connection before closing / unreffing gst_rtsp_connection_close() is not threadsafe on its own, this is a workaround at the client level, where we control both the watch and the connection
This commit is contained in:
parent
b4948f69a0
commit
90f7e851f4
1 changed files with 10 additions and 2 deletions
|
@ -1292,6 +1292,13 @@ gst_rtsp_client_close (GstRTSPClient * client)
|
|||
|
||||
GST_DEBUG ("client %p: closing connection", client);
|
||||
|
||||
g_mutex_lock (&priv->watch_lock);
|
||||
|
||||
/* Work around the lack of thread safety of gst_rtsp_connection_close */
|
||||
if (priv->watch) {
|
||||
gst_rtsp_watch_set_flushing (priv->watch, TRUE);
|
||||
}
|
||||
|
||||
if (priv->connection) {
|
||||
if ((tunnelid = gst_rtsp_connection_get_tunnelid (priv->connection))) {
|
||||
g_mutex_lock (&tunnels_lock);
|
||||
|
@ -1299,11 +1306,10 @@ gst_rtsp_client_close (GstRTSPClient * client)
|
|||
g_hash_table_remove (tunnels, tunnelid);
|
||||
g_mutex_unlock (&tunnels_lock);
|
||||
}
|
||||
gst_rtsp_connection_flush (priv->connection, TRUE);
|
||||
gst_rtsp_connection_close (priv->connection);
|
||||
}
|
||||
|
||||
/* connection is now closed, destroy the watch which will also cause the
|
||||
* closed signal to be emitted */
|
||||
if (priv->watch) {
|
||||
GST_DEBUG ("client %p: destroying watch", client);
|
||||
g_source_destroy ((GSource *) priv->watch);
|
||||
|
@ -1314,6 +1320,8 @@ gst_rtsp_client_close (GstRTSPClient * client)
|
|||
g_main_context_unref (priv->watch_context);
|
||||
priv->watch_context = NULL;
|
||||
}
|
||||
|
||||
g_mutex_unlock (&priv->watch_lock);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
|
Loading…
Reference in a new issue