diff options
author | Lars Wiréen <larswi@axis.com> | 2018-12-27 11:28:17 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2019-05-02 00:05:46 +0100 |
commit | cff88f072eafd9d0a93a66982951246e654e5892 (patch) | |
tree | 2c33df159959b9c64baed6f1f649084f9838a4c0 | |
parent | 8c595bcf4a93bc31158e3a8caa9170ded468b10c (diff) |
rtsp-media: Fix race condition in finish_unprepare
The previous fix for race condition around finish_unprepare where the
function could be called twice assumed that the status wouldn't change
during execution of the function. This assumption is incorrect as the
state may change, for example if an error message arrives from the
pipeline bus.
Instead a flag keeping track on whether the finish_unprepare function
is currently executing is introduced and checked.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/issues/59
-rw-r--r-- | gst/rtsp-server/rtsp-media.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 33f38f0..d6cc2b5 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -113,6 +113,7 @@ struct _GstRTSPMediaPrivate gint prepare_count; gint n_active; gboolean complete; + gboolean finishing_unprepare; /* the pipeline for the media */ GstElement *pipeline; @@ -3306,6 +3307,10 @@ finish_unprepare (GstRTSPMedia * media) gint i; GList *walk; + if (priv->finishing_unprepare) + return; + priv->finishing_unprepare = TRUE; + GST_DEBUG ("shutting down"); /* release the lock on shutdown, otherwise pad_added_cb might try to @@ -3316,9 +3321,6 @@ finish_unprepare (GstRTSPMedia * media) media_streams_set_blocked (media, FALSE); - if (priv->status != GST_RTSP_MEDIA_STATUS_UNPREPARING) - return; - for (i = 0; i < priv->streams->len; i++) { GstRTSPStream *stream; @@ -3371,6 +3373,8 @@ finish_unprepare (GstRTSPMedia * media) GST_DEBUG ("stop thread"); gst_rtsp_thread_stop (priv->thread); } + + priv->finishing_unprepare = FALSE; } /* called with state-lock */ |