diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-03-02 16:27:55 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-03-02 16:27:55 +0100 |
commit | de61b4502552be0ff578857d999ccef4bd6420c2 (patch) | |
tree | 92d343e4fbab47f4f4d38738b9b22952a9a4c225 /gst | |
parent | f957ee0aeb2902710e677b566c1ad36393ed0323 (diff) | |
download | gst-plugins-bad-de61b4502552be0ff578857d999ccef4bd6420c2.tar.gz gst-plugins-bad-de61b4502552be0ff578857d999ccef4bd6420c2.tar.bz2 gst-plugins-bad-de61b4502552be0ff578857d999ccef4bd6420c2.zip |
xdgmime: Add locking to the xdg_mime_* calls as it's not thread-safe
Diffstat (limited to 'gst')
-rw-r--r-- | gst/xdgmime/gstxdgmime.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gst/xdgmime/gstxdgmime.c b/gst/xdgmime/gstxdgmime.c index c2eec58d..1307779e 100644 --- a/gst/xdgmime/gstxdgmime.c +++ b/gst/xdgmime/gstxdgmime.c @@ -26,6 +26,8 @@ GST_DEBUG_CATEGORY (xdgmime_debug); #define GST_CAT_DEFAULT xdgmime_debug +G_LOCK_DEFINE_STATIC (xdg_lock); + static void xdgmime_typefind (GstTypeFind * find, gpointer user_data) { @@ -42,7 +44,14 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data) if ((data = gst_type_find_peek (find, 0, length)) == NULL) return; + /* FIXME: xdg-mime is not thread-safe as it stores the cache globally + * and updates it from every call if changes were done without + * any locking + */ + G_LOCK (xdg_lock); mimetype = xdg_mime_get_mime_type_for_data (data, length, &prio); + G_UNLOCK (xdg_lock); + if (mimetype == NULL || g_str_equal (mimetype, XDG_MIME_TYPE_UNKNOWN)) return; |