[balsa] Call lbc_init() only once.



commit b93675de4395b35984150859d9f34ffe6a43c0a9
Author: Pawel Salek <pawsa0 gmail com>
Date:   Sat Feb 16 15:53:24 2013 +0100

    Call lbc_init() only once.

 libbalsa/libbalsa-conf.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/libbalsa/libbalsa-conf.c b/libbalsa/libbalsa-conf.c
index e27c4b7..6f9a1c7 100644
--- a/libbalsa/libbalsa-conf.c
+++ b/libbalsa/libbalsa-conf.c
@@ -148,17 +148,18 @@ lbc_init(LibBalsaConf * conf, const gchar * filename,
 
 #ifdef BALSA_USE_THREADS
 static GRecMutex lbc_mutex;
-static gsize lbc_mutex_initialized = 0;
 
 static void
 lbc_lock(void)
 {
-    if (g_once_init_enter(&lbc_mutex_initialized)) {
-        g_rec_mutex_lock(&lbc_mutex);
-        g_once_init_leave(&lbc_mutex_initialized, 42);
+    static gboolean initialized = FALSE;
+
+    g_rec_mutex_lock(&lbc_mutex);
+    if (!initialized) {
+        lbc_init(&lbc_conf, "config", ".gnome2");
+        lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
+        initialized = TRUE;
     }
-    lbc_init(&lbc_conf, "config", ".gnome2");
-    lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
 }
 
 static void
@@ -170,8 +171,12 @@ lbc_unlock(void)
 static void
 lbc_lock(void)
 {
-    lbc_init(&lbc_conf, "config", ".gnome2");
-    lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
+    static gboolean initialized = FALSE;
+    if (!initialized) {
+        lbc_init(&lbc_conf, "config", ".gnome2");
+        lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
+        initialized = TRUE;
+    }
 }
 
 #define lbc_unlock()


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