[glib/wip/gcleanup] gcleanup: WIP more fixes for threading primitives cleanup



commit f5302d3da14d63e30a49300b201c5dd39b500e6f
Author: Stef Walter <stefw gnome org>
Date:   Thu Nov 7 22:36:31 2013 +0100

    gcleanup: WIP more fixes for threading primitives cleanup

 glib/deprecated/gthread-deprecated.c |   12 ++++++++++++
 glib/gthread-posix.c                 |    9 +--------
 2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/glib/deprecated/gthread-deprecated.c b/glib/deprecated/gthread-deprecated.c
index 89dba4d..09e3949 100644
--- a/glib/deprecated/gthread-deprecated.c
+++ b/glib/deprecated/gthread-deprecated.c
@@ -1429,6 +1429,13 @@ g_static_private_set (GStaticPrivate *private_key,
   node->owner = private_key;
 }
 
+static void
+cleanup_free_indices (void)
+{
+  g_slist_free (g_thread_free_indices);
+  g_thread_free_indices = NULL;
+}
+
 /**
  * g_static_private_free:
  * @private_key: a #GStaticPrivate to be freed
@@ -1455,6 +1462,11 @@ g_static_private_free (GStaticPrivate *private_key)
    * the same index.
    */
   G_LOCK (g_thread);
+  if (!g_thread_free_indices)
+    {
+      g_cleanup_list_push (G_CLEANUP_LIST, (GCleanupFunc)cleanup_free_indices,
+                           NULL, G_CLEANUP_PHASE_GRAVEYARD, "cleanup_free_indices");
+    }
   g_thread_free_indices = g_slist_prepend (g_thread_free_indices,
                                            GUINT_TO_POINTER (idx));
   G_UNLOCK (g_thread);
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index 43d7981..c367eb3 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -294,13 +294,6 @@ g_rec_mutex_impl_free (pthread_mutex_t *mutex)
   free (mutex);
 }
 
-static void
-g_rec_mutex_impl_cleanup (pthread_mutex_t *mutex)
-{
-  /* Perform actual cleanup in the next pass */
-  G_CLEANUP (mutex, g_rec_mutex_impl_free);
-}
-
 static pthread_mutex_t *
 g_rec_mutex_get_impl (GRecMutex *rec_mutex)
 {
@@ -310,7 +303,7 @@ g_rec_mutex_get_impl (GRecMutex *rec_mutex)
     {
       impl = g_rec_mutex_impl_new ();
       if (g_atomic_pointer_compare_and_exchange (&rec_mutex->p, NULL, impl))
-        g_cleanup_list_push (G_CLEANUP_LIST, (GCleanupFunc)g_rec_mutex_impl_cleanup, impl,
+        g_cleanup_list_push (G_CLEANUP_LIST, (GCleanupFunc)g_rec_mutex_impl_free, impl,
                              G_CLEANUP_PHASE_GRAVEYARD, G_STRFUNC);
       else
         g_rec_mutex_impl_free (impl);


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