element: clean up thread pool from gst_task_cleanup_all()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 8 Jul 2016 14:36:01 +0000 (16:36 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 8 Jul 2016 16:27:32 +0000 (17:27 +0100)
This ensures that all async operations (started from gst_element_call_async())
have been completed and so there is no extra thread running.

Fix races when checking for leaks on unit tests as some of those
operations were still running when the leaks tracer was checking for
leaked objects.

https://bugzilla.gnome.org/show_bug.cgi?id=768577

gst/gst_private.h
gst/gstelement.c
gst/gsttask.c

index ab7a979..049142c 100644 (file)
@@ -135,6 +135,9 @@ G_GNUC_INTERNAL  void  _priv_gst_allocator_cleanup (void);
 G_GNUC_INTERNAL  void  _priv_gst_caps_features_cleanup (void);
 G_GNUC_INTERNAL  void  _priv_gst_caps_cleanup (void);
 
+/* called from gst_task_cleanup_all(). */
+G_GNUC_INTERNAL  void  _priv_gst_element_cleanup (void);
+
 /* Private registry functions */
 G_GNUC_INTERNAL
 gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
index dd1f9dc..761627b 100644 (file)
@@ -3423,3 +3423,12 @@ gst_element_call_async (GstElement * element, GstElementCallAsyncFunc func,
 
   g_thread_pool_push (gst_element_pool, async_data, NULL);
 }
+
+void
+_priv_gst_element_cleanup (void)
+{
+  if (gst_element_pool) {
+    g_thread_pool_free (gst_element_pool, FALSE, TRUE);
+    gst_element_pool = NULL;
+  }
+}
index 2972e06..d8f17a7 100644 (file)
@@ -386,6 +386,9 @@ gst_task_cleanup_all (void)
   if ((klass = g_type_class_peek (GST_TYPE_TASK))) {
     init_klass_pool (klass);
   }
+
+  /* GstElement owns a GThreadPool */
+  _priv_gst_element_cleanup ();
 }
 
 /**