gst/gstinfo.c: Add mutex to serialise access to the hash table with the function...
authorTim-Philipp Müller <tim@centricular.net>
Wed, 21 Sep 2005 21:39:06 +0000 (21:39 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 21 Sep 2005 21:39:06 +0000 (21:39 +0000)
Original commit message from CVS:
Reviewed by: Tim-Philipp Müller  <tim at centricular dot net>
* gst/gstinfo.c: (_gst_debug_nameof_funcptr),
(_gst_debug_register_funcptr):
Add mutex to serialise access to the hash table with
the function pointer => function name string mapping;
make that hash table static scope (#316809).
* gst/registries/.cvsignore:
Remove left-over file.

ChangeLog
gst/gstinfo.c
gst/registries/.gitignore [deleted file]

index 1a5edb8..5d05019 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2005-09-21  Francis Labonte  <francis_labonte at hotmail dot com>
+
+       Reviewed by: Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst/gstinfo.c: (_gst_debug_nameof_funcptr),
+       (_gst_debug_register_funcptr):
+         Add mutex to serialise access to the hash table with
+         the function pointer => function name string mapping;
+         make that hash table static scope (#316809).
+
+       * gst/registries/.cvsignore:
+         Remove left-over file.
+
 2005-09-21  Tim-Philipp Müller  <tim at centricular dot net>
 
        * docs/pwg/appendix-porting.xml:
index b11be2f..e777a29 100644 (file)
@@ -1030,7 +1030,9 @@ gst_debug_get_all_categories (void)
 
 /*** FUNCTION POINTERS ********************************************************/
 
-GHashTable *__gst_function_pointers = NULL;
+static GHashTable *__gst_function_pointers;     /* NULL */
+static GStaticMutex __dbg_functions_mutex = G_STATIC_MUTEX_INIT;
+
 const gchar *
 _gst_debug_nameof_funcptr (GstDebugFuncPtr ptr)
     G_GNUC_NO_INSTRUMENT;
@@ -1045,9 +1047,12 @@ _gst_debug_nameof_funcptr (GstDebugFuncPtr ptr)
   Dl_info dlinfo;
 #endif
 
-  if (__gst_function_pointers
-      && (ptrname = g_hash_table_lookup (__gst_function_pointers, ptr))) {
-    return ptrname;
+  if (__gst_function_pointers) {
+    g_static_mutex_lock (&__dbg_functions_mutex);
+    ptrname = g_hash_table_lookup (__gst_function_pointers, ptr);
+    g_static_mutex_unlock (&__dbg_functions_mutex);
+    if (ptrname)
+      return ptrname;
   }
   /* we need to create an entry in the hash table for this one so we don't leak
    * the name */
@@ -1072,10 +1077,14 @@ _gst_debug_register_funcptr (GstDebugFuncPtr func, gchar * ptrname)
 {
   gpointer ptr = (gpointer) func;
 
+  g_static_mutex_lock (&__dbg_functions_mutex);
+
   if (!__gst_function_pointers)
     __gst_function_pointers = g_hash_table_new (g_direct_hash, g_direct_equal);
   if (!g_hash_table_lookup (__gst_function_pointers, ptr))
     g_hash_table_insert (__gst_function_pointers, ptr, ptrname);
+
+  g_static_mutex_unlock (&__dbg_functions_mutex);
 }
 
 #ifdef HAVE_PRINTF_EXTENSION
diff --git a/gst/registries/.gitignore b/gst/registries/.gitignore
deleted file mode 100644 (file)
index d11415d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-registrytest
-*.bb
-*.bbg
-*.da
-*.gcno