From 461811e2b2e6a3a82c27d2a8aeec25a71dc91e9a Mon Sep 17 00:00:00 2001 From: Fabrice Bellet Date: Tue, 23 May 2017 16:06:47 +0200 Subject: [PATCH] rtp: fix a double locking issue on the session The session value used in fs_rtp_stream_add_substream_unlock(), taken from the stream struct may be null, while the session value from fs_rtp_session_new_recv_pad() is not. However these two function depend on the same session value to properly lock and unlock it: the first function will unlock the session previously locked by the second function. --- gst/fsrtpconference/fs-rtp-session.c | 6 +++--- gst/fsrtpconference/fs-rtp-stream.c | 7 +++---- gst/fsrtpconference/fs-rtp-stream.h | 3 ++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c index a90dcfc..6f0101c 100644 --- a/gst/fsrtpconference/fs-rtp-session.c +++ b/gst/fsrtpconference/fs-rtp-session.c @@ -3287,7 +3287,7 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad, if (stream) { - if (!fs_rtp_stream_add_substream_unlock (stream, substream, &error)) + if (!fs_rtp_stream_add_substream_unlock (session, stream, substream, &error)) { g_prefix_error (&error, "Could not add the output ghostpad to the new substream: "); @@ -4360,7 +4360,7 @@ fs_rtp_session_associate_free_substreams (FsRtpSession *session, g_signal_handlers_disconnect_by_func (substream, "no-rtcp-timedout", session) > 0); - if (fs_rtp_stream_add_substream_unlock (stream, substream, &error)) + if (fs_rtp_stream_add_substream_unlock (session, stream, substream, &error)) { GST_DEBUG ("Associated SSRC %x in session %u", ssrc, session->id); } @@ -4485,7 +4485,7 @@ _substream_no_rtcp_timedout_cb (FsRtpSubStream *substream, first_stream = g_list_first (session->priv->streams)->data; g_object_ref (first_stream); - if (!fs_rtp_stream_add_substream_unlock (first_stream, substream, &error)) + if (!fs_rtp_stream_add_substream_unlock (session, first_stream, substream, &error)) { g_prefix_error (&error, "Could not link the substream to a stream: "); diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c index 1ef6b2e..52e1dec 100644 --- a/gst/fsrtpconference/fs-rtp-stream.c +++ b/gst/fsrtpconference/fs-rtp-stream.c @@ -1010,6 +1010,7 @@ _substream_unlinked (FsRtpSubStream *substream, gpointer user_data) /** * fs_rtp_stream_add_substream_unlock: + * @session: a #FsRtpSession * @stream: a #FsRtpStream * @substream: the #FsRtpSubStream to associate with this stream * @@ -1021,12 +1022,12 @@ _substream_unlinked (FsRtpSubStream *substream, gpointer user_data) * Returns: TRUE on success, FALSE on failure */ gboolean -fs_rtp_stream_add_substream_unlock (FsRtpStream *stream, +fs_rtp_stream_add_substream_unlock (FsRtpSession *session, + FsRtpStream *stream, FsRtpSubStream *substream, GError **error) { gboolean ret = TRUE; - FsRtpSession *session = fs_rtp_stream_get_session (stream, error); if (!session) return FALSE; @@ -1055,8 +1056,6 @@ fs_rtp_stream_add_substream_unlock (FsRtpStream *stream, else FS_RTP_SESSION_UNLOCK (session); - g_object_unref (session); - return ret; } diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h index a4b3fb2..105dd9b 100644 --- a/gst/fsrtpconference/fs-rtp-stream.h +++ b/gst/fsrtpconference/fs-rtp-stream.h @@ -115,7 +115,8 @@ FsRtpStream *fs_rtp_stream_new (FsRtpSession *session, stream_decrypt_clear_locked_cb decrypt_clear_locked_cb, gpointer user_data_for_cb); -gboolean fs_rtp_stream_add_substream_unlock (FsRtpStream *stream, +gboolean fs_rtp_stream_add_substream_unlock (FsRtpSession *session, + FsRtpStream *stream, FsRtpSubStream *substream, GError **error); -- 2.9.4