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.
This commit is contained in:
Göran Jönsson 2019-04-02 08:05:03 +02:00
parent cd46712162
commit 3cfe88632f

View file

@ -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);