summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantiago Carot-Nemesio <scarot@twilio.com>2019-03-08 16:19:29 +0100
committerTim-Philipp Müller <tim@centricular.com>2019-05-02 08:31:25 +0100
commitc6a33f76411c058225e011428adbc5002ac729a3 (patch)
treed3930ebef7306bacd4006fbeb56e38c1f5ce215b
parent949598d9879c1f4af122d1fc445163747e71e670 (diff)
downloadgstreamer-c6a33f76411c058225e011428adbc5002ac729a3.tar.gz
gsttaskpool: Do not block tasks while cleaning up the taskpool
There is a deadlock if any thread from the pool tries to push a new task while other thread is waiting for the pool of threads to finish. With this patch the thread will get an error when it tries to add a new task while the taskpool is being cleaned up.
-rw-r--r--gst/gsttaskpool.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gst/gsttaskpool.c b/gst/gsttaskpool.c
index a07820ffdd..89c8905e5f 100644
--- a/gst/gsttaskpool.c
+++ b/gst/gsttaskpool.c
@@ -81,15 +81,19 @@ default_prepare (GstTaskPool * pool, GError ** error)
static void
default_cleanup (GstTaskPool * pool)
{
+ GThreadPool *pool_;
+
GST_OBJECT_LOCK (pool);
- if (pool->pool) {
+ pool_ = pool->pool;
+ pool->pool = NULL;
+ GST_OBJECT_UNLOCK (pool);
+
+ if (pool_) {
/* Shut down all the threads, we still process the ones scheduled
* because the unref happens in the thread function.
* Also wait for currently running ones to finish. */
- g_thread_pool_free (pool->pool, FALSE, TRUE);
- pool->pool = NULL;
+ g_thread_pool_free (pool_, FALSE, TRUE);
}
- GST_OBJECT_UNLOCK (pool);
}
static gpointer