From 6136ef66d4333cc8cf17eb3b28f3746a0cf9346c Mon Sep 17 00:00:00 2001 From: Kseniia Date: Mon, 5 Sep 2016 18:31:36 +0300 Subject: [PATCH] rtsp-session: Fix segfault when doing keep-alive after removing the session If keep-alive happens after removing the session but before finalizing the stream transport, we would segfault. https://bugzilla.gnome.org/show_bug.cgi?id=750544 --- gst/rtsp-server/rtsp-session.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gst/rtsp-server/rtsp-session.c b/gst/rtsp-server/rtsp-session.c index 10f5648..8c664e2 100644 --- a/gst/rtsp-server/rtsp-session.c +++ b/gst/rtsp-server/rtsp-session.c @@ -250,6 +250,26 @@ gst_rtsp_session_manage_media (GstRTSPSession * sess, const gchar * path, return result; } +static void +gst_rtsp_session_unset_transport_keepalive (GstRTSPSessionMedia * sessmedia) +{ + GstRTSPMedia *media; + guint i, n_streams; + + media = gst_rtsp_session_media_get_media (sessmedia); + n_streams = gst_rtsp_media_n_streams (media); + + for (i = 0; i < n_streams; i++) { + GstRTSPStreamTransport *transport = + gst_rtsp_session_media_get_transport (sessmedia, i); + + if (!transport) + continue; + + gst_rtsp_stream_transport_set_keepalive (transport, NULL, NULL, NULL); + } +} + /** * gst_rtsp_session_release_media: * @sess: a #GstRTSPSession @@ -281,6 +301,9 @@ gst_rtsp_session_release_media (GstRTSPSession * sess, more = (priv->medias != NULL); g_mutex_unlock (&priv->lock); + if (find && !more) + gst_rtsp_session_unset_transport_keepalive (media); + if (find) g_object_unref (media); -- 2.7.4