summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@osg.samsung.com>2017-05-20 13:24:18 +0200
committerThibault Saunier <thibault.saunier@osg.samsung.com>2017-05-20 15:42:16 +0200
commitbd73551cc0385ace0001af049f59d398c48d3c0d (patch)
tree0f9fc41a05d1975faa8d24a45167ffdc9d467607
parente3ab5e4df9cb43ac71645edfe5b703d20e5d680b (diff)
leaks: Handle subclasses in filters even for unhandled/lazy loaded types
Using typename in the set of unhandled types instead of the quark so that we also handle subclasses as with other filters.
-rw-r--r--plugins/tracers/gstleaks.c44
-rw-r--r--plugins/tracers/gstleaks.h2
2 files changed, 27 insertions, 19 deletions
diff --git a/plugins/tracers/gstleaks.c b/plugins/tracers/gstleaks.c
index 5960c91a5..04a8abb6f 100644
--- a/plugins/tracers/gstleaks.c
+++ b/plugins/tracers/gstleaks.c
@@ -139,10 +139,10 @@ set_filters (GstLeaksTracer * self, const gchar * filters)
* should_handle_object_type() when/if the object type is actually
* used. */
if (!self->unhandled_filter)
- self->unhandled_filter = g_hash_table_new (NULL, NULL);
+ self->unhandled_filter = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
- g_hash_table_add (self->unhandled_filter,
- GUINT_TO_POINTER (g_quark_from_string (tmp[i])));
+ g_hash_table_add (self->unhandled_filter, g_strdup (tmp[i]));
g_atomic_int_inc (&self->unhandled_filter_count);
continue;
}
@@ -194,6 +194,23 @@ set_stacktrace:
}
static gboolean
+_expand_unhandled_filters (gchar * typename, gpointer unused_value,
+ GstLeaksTracer * self)
+{
+ GType type;
+
+ type = g_type_from_name (typename);
+
+ if (type == 0)
+ return FALSE;
+
+ g_atomic_int_dec_and_test (&self->unhandled_filter_count);
+ g_array_append_val (self->filter, type);
+
+ return TRUE;
+}
+
+static gboolean
should_handle_object_type (GstLeaksTracer * self, GType object_type)
{
guint i, len;
@@ -202,23 +219,14 @@ should_handle_object_type (GstLeaksTracer * self, GType object_type)
/* No filtering, handle all types */
return TRUE;
- if (g_atomic_int_get (&self->unhandled_filter_count)) {
- GST_OBJECT_LOCK (self);
- if (self->unhandled_filter) {
- GQuark q;
-
- q = g_type_qname (object_type);
- if (g_hash_table_contains (self->unhandled_filter, GUINT_TO_POINTER (q))) {
- g_array_append_val (self->filter, object_type);
- g_hash_table_remove (self->unhandled_filter, GUINT_TO_POINTER (q));
+ if (object_type == 0)
+ return FALSE;
- if (g_atomic_int_dec_and_test (&self->unhandled_filter_count))
- g_clear_pointer (&self->unhandled_filter, g_hash_table_unref);
- GST_OBJECT_UNLOCK (self);
- return TRUE;
- }
- }
+ if (g_atomic_int_get (&self->unhandled_filter_count)) {
+ GST_OBJECT_LOCK (self);
+ g_hash_table_foreach_remove (self->unhandled_filter,
+ (GHRFunc) _expand_unhandled_filters, self);
GST_OBJECT_UNLOCK (self);
}
diff --git a/plugins/tracers/gstleaks.h b/plugins/tracers/gstleaks.h
index 339bae89c..71277b8cf 100644
--- a/plugins/tracers/gstleaks.h
+++ b/plugins/tracers/gstleaks.h
@@ -60,7 +60,7 @@ struct _GstLeaksTracer {
GHashTable *added;
/* Set of owned ObjectLog. Protected by object lock */
GHashTable *removed;
- /* If not NULL, contain a set of GQuark representing type filter not
+ /* If not NULL, contain a set of string representing type filter not
* (yet?) known by the type system.
* Protected by object lock. */
GHashTable *unhandled_filter;