diff options
author | Göran Jönsson <goranjn@axis.com> | 2019-04-02 08:05:03 +0200 |
---|---|---|
committer | Göran Jönsson <goranjn@axis.com> | 2019-04-11 08:02:52 +0200 |
commit | 3cfe88632fc4896dcf4107baae06c9f165d54bf6 (patch) | |
tree | f941e7cf84a80f8b0f5b31a8b606ddee0d005b99 | |
parent | cd467121623bf16a4a6eb47029f147dceb1e2be4 (diff) |
rtsp_server: Free thread pool before clean transport cache
If not waiting for free thread pool before clean transport caches, there
can be a crash if a thread is executing in transport list loop in
function send_tcp_message.
Also add a check if priv->send_pool in on_message_sent to avoid that a
new thread is pushed during wait of free thread pool. This is possible
since when waiting for free thread pool mutex have to be unlocked.
-rw-r--r-- | gst/rtsp-server/rtsp-stream.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c index e6721a2d8a..e6ba6c1d59 100644 --- a/gst/rtsp-server/rtsp-stream.c +++ b/gst/rtsp-server/rtsp-stream.c @@ -3836,6 +3836,16 @@ gst_rtsp_stream_leave_bin (GstRTSPStream * stream, GstBin * bin, if (priv->transports != NULL) goto transports_not_removed; + if (priv->send_pool) { + GThreadPool *slask; + + slask = priv->send_pool; + priv->send_pool = NULL; + g_mutex_unlock (&priv->lock); + g_thread_pool_free (slask, TRUE, TRUE); + g_mutex_lock (&priv->lock); + } + clear_tr_cache (priv, TRUE); clear_tr_cache (priv, FALSE); @@ -4426,8 +4436,10 @@ on_message_sent (gpointer user_data) if (idx != -1) { gint dummy; - GST_DEBUG_OBJECT (stream, "start thread"); - g_thread_pool_push (priv->send_pool, &dummy, NULL); + if (priv->send_pool) { + GST_DEBUG_OBJECT (stream, "start thread"); + g_thread_pool_push (priv->send_pool, &dummy, NULL); + } } g_mutex_unlock (&priv->lock); |