From 9e46ef946571f1cbd31a80236c7317c23f8b9b74 Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Tue, 9 Jan 2001 13:47:12 +0000 Subject: [PATCH] Made g_profile_mutex a GMutex* instead of G_LOCK_DEFINE_STATIC to avoid 2001-01-09 Sebastian Wilhelmi * gmem.c: Made g_profile_mutex a GMutex* instead of G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations without native static mutexes. Contruct g_profile_mutex in g_mem_init(). --- ChangeLog | 7 +++++++ ChangeLog.pre-2-0 | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-12 | 7 +++++++ ChangeLog.pre-2-2 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ glib/gmem.c | 15 ++++++++------- gmem.c | 15 ++++++++------- 10 files changed, 72 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e60410..8bedfaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 0e60410..8bedfaf 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0e60410..8bedfaf 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 0e60410..8bedfaf 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 0e60410..8bedfaf 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 0e60410..8bedfaf 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 0e60410..8bedfaf 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 0e60410..8bedfaf 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2001-01-09 Sebastian Wilhelmi + + * gmem.c: Made g_profile_mutex a GMutex* instead of + G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations + without native static mutexes. Contruct g_profile_mutex in + g_mem_init(). + 2001-01-06 Tor Lillqvist * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using diff --git a/glib/gmem.c b/glib/gmem.c index b0909a0..bcdc7fc 100644 --- a/glib/gmem.c +++ b/glib/gmem.c @@ -266,7 +266,7 @@ static gulong profile_mc_allocs = 0; static gulong profile_zinit = 0; static gulong profile_frees = 0; static gulong profile_mc_frees = 0; -G_LOCK_DEFINE_STATIC (g_profile_mutex); +static GMutex *g_profile_mutex = NULL; #ifdef G_ENABLE_DEBUG static volatile gulong glib_trap_free_size = 0; static volatile gulong glib_trap_realloc_size = 0; @@ -280,13 +280,13 @@ profiler_log (ProfilerJob job, gulong n_bytes, gboolean success) { - G_LOCK (g_profile_mutex); + g_mutex_lock (g_profile_mutex); if (!profile_data) { profile_data = standard_malloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); if (!profile_data) /* memory system kiddin' me, eh? */ { - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); return; } } @@ -320,7 +320,7 @@ profiler_log (ProfilerJob job, else profile_mc_frees += n_bytes; } - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); } static void @@ -369,11 +369,11 @@ g_mem_profile (void) gulong local_mc_allocs = profile_mc_allocs; gulong local_mc_frees = profile_mc_frees; - G_LOCK (g_profile_mutex); + g_mutex_lock (g_profile_mutex); if (!profile_data) { - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); return; } @@ -395,7 +395,7 @@ g_mem_profile (void) local_mc_frees, ((gdouble) local_mc_frees) / local_mc_allocs * 100.0, local_mc_allocs - local_mc_frees); - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); } static gpointer @@ -1250,5 +1250,6 @@ g_mem_init (void) #endif #ifndef G_DISABLE_CHECKS mem_chunk_recursion = g_private_new (NULL); + g_profile_mutex = g_mutex_new (); #endif } diff --git a/gmem.c b/gmem.c index b0909a0..bcdc7fc 100644 --- a/gmem.c +++ b/gmem.c @@ -266,7 +266,7 @@ static gulong profile_mc_allocs = 0; static gulong profile_zinit = 0; static gulong profile_frees = 0; static gulong profile_mc_frees = 0; -G_LOCK_DEFINE_STATIC (g_profile_mutex); +static GMutex *g_profile_mutex = NULL; #ifdef G_ENABLE_DEBUG static volatile gulong glib_trap_free_size = 0; static volatile gulong glib_trap_realloc_size = 0; @@ -280,13 +280,13 @@ profiler_log (ProfilerJob job, gulong n_bytes, gboolean success) { - G_LOCK (g_profile_mutex); + g_mutex_lock (g_profile_mutex); if (!profile_data) { profile_data = standard_malloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); if (!profile_data) /* memory system kiddin' me, eh? */ { - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); return; } } @@ -320,7 +320,7 @@ profiler_log (ProfilerJob job, else profile_mc_frees += n_bytes; } - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); } static void @@ -369,11 +369,11 @@ g_mem_profile (void) gulong local_mc_allocs = profile_mc_allocs; gulong local_mc_frees = profile_mc_frees; - G_LOCK (g_profile_mutex); + g_mutex_lock (g_profile_mutex); if (!profile_data) { - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); return; } @@ -395,7 +395,7 @@ g_mem_profile (void) local_mc_frees, ((gdouble) local_mc_frees) / local_mc_allocs * 100.0, local_mc_allocs - local_mc_frees); - G_UNLOCK (g_profile_mutex); + g_mutex_unlock (g_profile_mutex); } static gpointer @@ -1250,5 +1250,6 @@ g_mem_init (void) #endif #ifndef G_DISABLE_CHECKS mem_chunk_recursion = g_private_new (NULL); + g_profile_mutex = g_mutex_new (); #endif } -- 2.7.4