[gmime] Fixed mutex locking



commit d08a167d4e2245903d49bc7ec8e611dc89f26420
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sat Feb 18 14:22:03 2017 -0500

    Fixed mutex locking

 gmime/gmime-charset.c     |   10 +++++-----
 gmime/gmime-iconv-utils.c |   10 +++++-----
 gmime/gmime-iconv.c       |   10 +++++-----
 3 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/gmime/gmime-charset.c b/gmime/gmime-charset.c
index 9ed635a..1442cb0 100644
--- a/gmime/gmime-charset.c
+++ b/gmime/gmime-charset.c
@@ -170,9 +170,9 @@ static char *locale_lang = NULL;
 static int initialized = 0;
 
 #ifdef G_THREADS_ENABLED
-G_LOCK_DEFINE_STATIC (lock);
-#define CHARSET_UNLOCK() G_UNLOCK (lock)
-#define CHARSET_LOCK() G_UNLOCK (lock)
+static GMutex lock;
+#define CHARSET_UNLOCK() g_mutex_unlock (&lock);
+#define CHARSET_LOCK() g_mutex_lock (&lock);
 #else
 #define CHARSET_UNLOCK()
 #define CHARSET_LOCK()
@@ -197,7 +197,7 @@ g_mime_charset_map_shutdown (void)
                 * internal mutex pointer to NULL, so re-initializing
                 * GMime would not properly re-initialize the mutexes.
                 **/
-               g_mutex_clear (&G_LOCK_NAME (lock));
+               g_mutex_clear (&lock);
        }
 #endif
        
@@ -272,7 +272,7 @@ g_mime_charset_map_init (void)
                return;
        
 #ifdef G_THREADS_ENABLED
-       g_mutex_init (&G_LOCK_NAME (lock));
+       g_mutex_init (&lock);
 #endif
        
        iconv_charsets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
diff --git a/gmime/gmime-iconv-utils.c b/gmime/gmime-iconv-utils.c
index 6a2595b..26a00bb 100644
--- a/gmime/gmime-iconv-utils.c
+++ b/gmime/gmime-iconv-utils.c
@@ -48,9 +48,9 @@
 
 
 #ifdef G_THREADS_ENABLED
-G_LOCK_DEFINE_STATIC (iconv_utils);
-#define UNLOCK() G_UNLOCK (iconv_utils)
-#define LOCK()   G_LOCK (iconv_utils)
+static GMutex lock;
+#define UNLOCK() g_mutex_unlock (&lock)
+#define LOCK()   g_mutex_lock (&lock);
 #else
 #define UNLOCK()
 #define LOCK()
@@ -72,7 +72,7 @@ g_mime_iconv_utils_init (void)
                return;
        
 #ifdef G_THREADS_ENABLED
-       g_mutex_init (&G_LOCK_NAME (iconv_utils));
+       g_mutex_init (&lock);
 #endif
        
        utf8 = g_mime_charset_iconv_name ("UTF-8");
@@ -99,7 +99,7 @@ g_mime_iconv_utils_shutdown (void)
                 * internal mutex pointer to NULL, so re-initializing
                 * GMime would not properly re-initialize the mutexes.
                 **/
-               g_mutex_clear (&G_LOCK_NAME (iconv_utils));
+               g_mutex_clear (&lock);
        }
 #endif
        
diff --git a/gmime/gmime-iconv.c b/gmime/gmime-iconv.c
index 259025c..4c7d5a2 100644
--- a/gmime/gmime-iconv.c
+++ b/gmime/gmime-iconv.c
@@ -80,9 +80,9 @@ static int shutdown = 0;
 #endif /* GMIME_ICONV_DEBUG */
 
 #ifdef G_THREADS_ENABLED
-G_LOCK_DEFINE_STATIC (lock);
-#define ICONV_CACHE_UNLOCK() G_UNLOCK (lock)
-#define ICONV_CACHE_LOCK()   G_LOCK (lock)
+static GMutex lock;
+#define ICONV_CACHE_UNLOCK() g_mutex_unlock (&lock);
+#define ICONV_CACHE_LOCK()   g_mutex_lock (&lock);
 #else
 #define ICONV_CACHE_UNLOCK()
 #define ICONV_CACHE_LOCK()
@@ -196,7 +196,7 @@ g_mime_iconv_shutdown (void)
                 * internal mutex pointer to NULL, so re-initializing
                 * GMime would not properly re-initialize the mutexes.
                 **/
-               g_mutex_clear (&G_LOCK_NAME (lock));
+               g_mutex_clear (&lock);
        }
 #endif
        
@@ -226,7 +226,7 @@ g_mime_iconv_init (void)
                return;
        
 #ifdef G_THREADS_ENABLED
-       g_mutex_init (&G_LOCK_NAME (lock));
+       g_mutex_init (&lock);
 #endif
        
        g_mime_charset_map_init ();


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