From: Stewart Brodie Date: Sat, 18 Jan 2014 13:43:20 +0000 (+0100) Subject: iterator: Preserve the master lock when creating recursive iterator filters with... X-Git-Tag: 1.3.1~206 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f77d79f2f8eae2e10b664ef83e7ea97a4b9e762b;p=platform%2Fupstream%2Fgstreamer.git iterator: Preserve the master lock when creating recursive iterator filters with the same lock This way we make sure that a) the lock is always taken when checking the cookie and calling the iterator's next functions and b) it is not taken while calling any of the iterator filter functions. https://bugzilla.gnome.org/show_bug.cgi?id=711138 --- diff --git a/gst/gstiterator.c b/gst/gstiterator.c index f2b49936ff..ae579423f3 100644 --- a/gst/gstiterator.c +++ b/gst/gstiterator.c @@ -459,6 +459,7 @@ typedef struct _GstIteratorFilter GstIterator iterator; GstIterator *slave; + GMutex *master_lock; GCompareFunc func; GValue user_data; gboolean have_user_data; @@ -475,15 +476,15 @@ filter_next (GstIteratorFilter * it, GValue * elem) result = gst_iterator_next (it->slave, &item); switch (result) { case GST_ITERATOR_OK: - if (G_LIKELY (GST_ITERATOR (it)->lock)) - g_mutex_unlock (GST_ITERATOR (it)->lock); + if (G_LIKELY (it->master_lock)) + g_mutex_unlock (it->master_lock); if (it->func (&item, &it->user_data) == 0) { g_value_copy (&item, elem); done = TRUE; } g_value_reset (&item); - if (G_LIKELY (GST_ITERATOR (it)->lock)) - g_mutex_lock (GST_ITERATOR (it)->lock); + if (G_LIKELY (it->master_lock)) + g_mutex_lock (it->master_lock); break; case GST_ITERATOR_RESYNC: case GST_ITERATOR_DONE: @@ -559,6 +560,7 @@ gst_iterator_filter (GstIterator * it, GCompareFunc func, (GstIteratorResyncFunction) filter_resync, (GstIteratorFreeFunction) filter_free); + result->master_lock = it->lock; it->lock = NULL; result->func = func; if (user_data) {