[glib] giomodule: make the default_modules mutex recursive



commit 95cab96515d84a9bc5dd731ea6eee08d7e786f50
Author: Dan Winship <danw gnome org>
Date:   Wed Oct 12 13:57:44 2011 -0400

    giomodule: make the default_modules mutex recursive
    
    It is possible for _g_io_module_get_default() to be called recursively
    (eg, if a module of one type is loaded that tries to look up gsettings
    from its init() method and ends up causing the gsettings module to be
    loaded). So use a recursive mutex.

 gio/giomodule.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gio/giomodule.c b/gio/giomodule.c
index 61638c0..c7a0020 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -630,7 +630,7 @@ g_io_modules_load_all_in_directory (const char *dirname)
   return g_io_modules_load_all_in_directory_with_scope (dirname, NULL);
 }
 
-G_LOCK_DEFINE_STATIC (default_modules);
+GRecMutex default_modules_lock;
 GHashTable *default_modules;
 
 static gpointer
@@ -692,7 +692,7 @@ _g_io_module_get_default (const gchar         *extension_point,
   GIOExtension *extension, *preferred;
   gpointer impl;
 
-  G_LOCK (default_modules);
+  g_rec_mutex_lock (&default_modules_lock);
   if (default_modules)
     {
       gpointer key;
@@ -700,7 +700,7 @@ _g_io_module_get_default (const gchar         *extension_point,
       if (g_hash_table_lookup_extended (default_modules, extension_point,
 					&key, &impl))
 	{
-	  G_UNLOCK (default_modules);
+	  g_rec_mutex_unlock (&default_modules_lock);
 	  return impl;
 	}
     }
@@ -715,7 +715,7 @@ _g_io_module_get_default (const gchar         *extension_point,
   if (!ep)
     {
       g_warn_if_reached ();
-      G_UNLOCK (default_modules);
+      g_rec_mutex_unlock (&default_modules_lock);
       return NULL;
     }
 
@@ -752,7 +752,7 @@ _g_io_module_get_default (const gchar         *extension_point,
   g_hash_table_insert (default_modules,
 		       g_strdup (extension_point),
 		       impl ? g_object_ref (impl) : NULL);
-  G_UNLOCK (default_modules);
+  g_rec_mutex_unlock (&default_modules_lock);
 
   return impl;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]