summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2014-07-01 14:41:14 +0200
committerWim Taymans <wtaymans@redhat.com>2014-07-01 14:41:14 +0200
commit5e2afcefdda5066641c01d243444c4f670054de0 (patch)
treea36933c258bede7e1c6a66ce6a7da820b7b2cc48
parentfe081e73015dc269d585f4be3efbc0d93ead128b (diff)
client: protect sessions with lock
Protect the list of sessions with the lock. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=732226
-rw-r--r--gst/rtsp-server/rtsp-client.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c
index 0c0685c..e442209 100644
--- a/gst/rtsp-server/rtsp-client.c
+++ b/gst/rtsp-server/rtsp-client.c
@@ -297,14 +297,18 @@ client_watch_session (GstRTSPClient * client, GstRTSPSession * session)
{
GstRTSPClientPrivate *priv = client->priv;
- /* we already know about this session */
- if (g_list_find (priv->sessions, session) != NULL)
- return;
+ g_mutex_lock (&priv->lock);
+ /* check if we already know about this session */
+ if (g_list_find (priv->sessions, session) = NULL) {
+ GST_INFO ("watching session %p", session);
+ priv->sessions = g_list_prepend (priv->sessions, g_object_ref (session));
+ }
+ g_mutex_unlock (&priv->lock);
- GST_INFO ("watching session %p", session);
- priv->sessions = g_list_prepend (priv->sessions, g_object_ref (session));
+ return;
}
+/* should be called with lock */
static void
client_unwatch_session (GstRTSPClient * client, GstRTSPSession * session,
GList * link)
@@ -318,12 +322,12 @@ client_unwatch_session (GstRTSPClient * client, GstRTSPSession * session,
if (link == NULL)
return;
}
+ priv->sessions = g_list_delete_link (priv->sessions, link);
/* unlink all media managed in this session */
gst_rtsp_session_filter (session, filter_session_media, client);
/* remove the session */
- priv->sessions = g_list_delete_link (priv->sessions, link);
g_object_unref (session);
}
@@ -2235,8 +2239,13 @@ static void
client_session_removed (GstRTSPSessionPool * pool, GstRTSPSession * session,
GstRTSPClient * client)
{
+ GstRTSPClientPrivate *priv = client->priv;
+
GST_INFO ("client %p: session %p removed", client, session);
+
+ g_mutex_lock (&priv->lock);
client_unwatch_session (client, session, NULL);
+ g_mutex_unlock (&priv->lock);
}
/* Returns TRUE if there are no Require headers, otherwise returns FALSE