From a70206f1770b436525fb151e954d0aa60e2ef051 Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Fri, 18 May 2001 08:36:44 +0000 Subject: [PATCH] Fixed mutex deadlock. 2001-05-18 Sebastian Wilhelmi * gmem.c (g_mem_profile): Fixed mutex deadlock. --- ChangeLog | 4 ++++ ChangeLog.pre-2-0 | 4 ++++ ChangeLog.pre-2-10 | 4 ++++ ChangeLog.pre-2-12 | 4 ++++ ChangeLog.pre-2-2 | 4 ++++ ChangeLog.pre-2-4 | 4 ++++ ChangeLog.pre-2-6 | 4 ++++ ChangeLog.pre-2-8 | 4 ++++ glib/gmem.c | 22 +++++++++++++++------- gmem.c | 22 +++++++++++++++------- 10 files changed, 62 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index be08eed..a4922ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index be08eed..a4922ba 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index be08eed..a4922ba 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index be08eed..a4922ba 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index be08eed..a4922ba 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index be08eed..a4922ba 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index be08eed..a4922ba 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index be08eed..a4922ba 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,7 @@ +2001-05-18 Sebastian Wilhelmi + + * gmem.c (g_mem_profile): Fixed mutex deadlock. + 2001-05-17 Sebastian Wilhelmi * makefile.mingw.in: Add gpattern.o to objects. diff --git a/glib/gmem.c b/glib/gmem.c index 805f6bd..616614b 100644 --- a/glib/gmem.c +++ b/glib/gmem.c @@ -363,22 +363,31 @@ void g_mem_profile (void) { guint local_data[(MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])]; - gulong local_allocs = profile_allocs; - gulong local_zinit = profile_zinit; - gulong local_frees = profile_frees; - gulong local_mc_allocs = profile_mc_allocs; - gulong local_mc_frees = profile_mc_frees; + gulong local_allocs; + gulong local_zinit; + gulong local_frees; + gulong local_mc_allocs; + gulong local_mc_frees; g_mutex_lock (g_profile_mutex); + local_allocs = profile_allocs; + local_zinit = profile_zinit; + local_frees = profile_frees; + local_mc_allocs = profile_mc_allocs; + local_mc_frees = profile_mc_frees; + if (!profile_data) { g_mutex_unlock (g_profile_mutex); return; } - memcpy (local_data, profile_data, (MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); + memcpy (local_data, profile_data, + (MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); + g_mutex_unlock (g_profile_mutex); + g_print ("GLib Memory statistics (successful operations):\n"); profile_print_locked (local_data, TRUE); g_print ("GLib Memory statistics (failing operations):\n"); @@ -395,7 +404,6 @@ g_mem_profile (void) local_mc_frees, ((gdouble) local_mc_frees) / local_mc_allocs * 100.0, local_mc_allocs - local_mc_frees); - g_mutex_unlock (g_profile_mutex); } static gpointer diff --git a/gmem.c b/gmem.c index 805f6bd..616614b 100644 --- a/gmem.c +++ b/gmem.c @@ -363,22 +363,31 @@ void g_mem_profile (void) { guint local_data[(MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])]; - gulong local_allocs = profile_allocs; - gulong local_zinit = profile_zinit; - gulong local_frees = profile_frees; - gulong local_mc_allocs = profile_mc_allocs; - gulong local_mc_frees = profile_mc_frees; + gulong local_allocs; + gulong local_zinit; + gulong local_frees; + gulong local_mc_allocs; + gulong local_mc_frees; g_mutex_lock (g_profile_mutex); + local_allocs = profile_allocs; + local_zinit = profile_zinit; + local_frees = profile_frees; + local_mc_allocs = profile_mc_allocs; + local_mc_frees = profile_mc_frees; + if (!profile_data) { g_mutex_unlock (g_profile_mutex); return; } - memcpy (local_data, profile_data, (MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); + memcpy (local_data, profile_data, + (MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); + g_mutex_unlock (g_profile_mutex); + g_print ("GLib Memory statistics (successful operations):\n"); profile_print_locked (local_data, TRUE); g_print ("GLib Memory statistics (failing operations):\n"); @@ -395,7 +404,6 @@ g_mem_profile (void) local_mc_frees, ((gdouble) local_mc_frees) / local_mc_allocs * 100.0, local_mc_allocs - local_mc_frees); - g_mutex_unlock (g_profile_mutex); } static gpointer -- 2.7.4