From 1ffedb43a362c8e22c9e47bce376ade12bc7c9f5 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 9 Jan 2005 01:35:01 +0000 Subject: [PATCH] gst/gstpluginfeature.c: Protect plugin loading by a mutex so it's threadsafe. Fixes #163234. Original commit message from CVS: Reviewed by: Ronald S. Bultje * gst/gstpluginfeature.c: (gst_plugin_feature_ensure_loaded): Protect plugin loading by a mutex so it's threadsafe. Fixes #163234. --- ChangeLog | 8 ++++++++ gst/gstpluginfeature.c | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index eaf7fb5..ea20bd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-01-09 Sebastien Cote + + Reviewed by: Ronald S. Bultje + + * gst/gstpluginfeature.c: (gst_plugin_feature_ensure_loaded): + Protect plugin loading by a mutex so it's threadsafe. Fixes + #163234. + 2005-01-08 Ronald S. Bultje * gst/gstevent.c: (_gst_event_copy): diff --git a/gst/gstpluginfeature.c b/gst/gstpluginfeature.c index 2c90689..b16c10c 100644 --- a/gst/gstpluginfeature.c +++ b/gst/gstpluginfeature.c @@ -91,11 +91,13 @@ gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature * feature) { GstPlugin *plugin; + static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_return_val_if_fail (feature != NULL, FALSE); g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE); plugin = (GstPlugin *) (feature->manager); + g_static_mutex_lock (&mutex); if (plugin && !gst_plugin_is_loaded (plugin)) { #ifndef GST_DISABLE_REGISTRY @@ -104,12 +106,21 @@ gst_plugin_feature_ensure_loaded (GstPluginFeature * feature) "loading plugin %s for feature", plugin->desc.name); if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), - plugin) != GST_REGISTRY_OK) + plugin) != GST_REGISTRY_OK) { + g_static_mutex_unlock (&mutex); return FALSE; - } else -#endif /* GST_DISABLE_REGISTRY */ + } + } else { + g_static_mutex_unlock (&mutex); return FALSE; + } +#else /* GST_DISABLE_REGISTRY */ + g_static_mutex_unlock (&mutex); + return FALSE; +#endif } + + g_static_mutex_unlock (&mutex); return TRUE; } -- 2.7.4