summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-06-05 17:36:17 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-06-05 17:36:17 +0000
commitbcc342b81ba5d0b9cbef0dd60ec20ea70b37dac3 (patch)
treeaaee22906c6c9e3ebbf7346679a2ad7639ade211
parentcc4b0a54528bad2cf0fc6ea1b90c31d7aa5f4305 (diff)
Don't deadlock when running with threads. (#444121, Christian Persch)
2007-06-05 Matthias Clasen <mclasen@redhat.com> * glib/gutils.c (g_get_user_special_dir): Don't deadlock when running with threads. (#444121, Christian Persch) svn path=/trunk/; revision=5535
-rw-r--r--ChangeLog5
-rw-r--r--glib/gutils.c62
2 files changed, 42 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d0e07b4f..2b6b2e52a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-06-05 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/gutils.c (g_get_user_special_dir): Don't deadlock
+ when running with threads. (#444121, Christian Persch)
+
2007-06-05 Vincent Untz <vuntz@gnome.org>
* glib/goption.c: (g_option_context_get_help): don't replace the usage
diff --git a/glib/gutils.c b/glib/gutils.c
index 89413494c..6565e8eb1 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -2008,26 +2008,10 @@ g_get_user_data_dir (void)
return data_dir;
}
-/**
- * g_get_user_config_dir:
- *
- * Returns a base directory in which to store user-specific application
- * configuration information such as user preferences and settings.
- *
- * On UNIX platforms this is determined using the mechanisms described in
- * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
- * XDG Base Directory Specification</ulink>
- *
- * Return value: a string owned by GLib that must not be modified
- * or freed.
- * Since: 2.6
- **/
-G_CONST_RETURN gchar*
-g_get_user_config_dir (void)
+static void
+g_init_user_config_dir (void)
{
- gchar *config_dir;
-
- G_LOCK (g_utils_global);
+ gchar *config_dir;
if (!g_user_config_dir)
{
@@ -2048,14 +2032,35 @@ g_get_user_config_dir (void)
else
config_dir = g_build_filename (g_tmp_dir, g_user_name, ".config", NULL);
}
+
g_user_config_dir = config_dir;
}
- else
- config_dir = g_user_config_dir;
+}
+
+/**
+ * g_get_user_config_dir:
+ *
+ * Returns a base directory in which to store user-specific application
+ * configuration information such as user preferences and settings.
+ *
+ * On UNIX platforms this is determined using the mechanisms described in
+ * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
+ * XDG Base Directory Specification</ulink>
+ *
+ * Return value: a string owned by GLib that must not be modified
+ * or freed.
+ * Since: 2.6
+ **/
+G_CONST_RETURN gchar*
+g_get_user_config_dir (void)
+{
+ G_LOCK (g_utils_global);
+
+ g_init_user_config_dir ();
G_UNLOCK (g_utils_global);
- return config_dir;
+ return g_user_config_dir;
}
/**
@@ -2221,7 +2226,7 @@ maybe_expire_user_special_dirs (void)
g_user_special_dirs_stat_time = now;
- config_file = g_build_filename (g_get_user_config_dir (),
+ config_file = g_build_filename (g_user_config_dir,
"user-dirs.dirs",
NULL);
@@ -2246,6 +2251,9 @@ out:
g_free (config_file);
}
+
+static void g_init_user_config_dir (void);
+
/* adapted from xdg-user-dir-lookup.c
*
* Copyright (C) 2007 Red Hat Inc.
@@ -2278,7 +2286,8 @@ load_user_special_dirs (void)
gchar **lines;
gint n_lines, i;
- config_file = g_build_filename (g_get_user_config_dir (),
+ g_init_user_config_dir ();
+ config_file = g_build_filename (g_user_config_dir,
"user-dirs.dirs",
NULL);
@@ -2387,7 +2396,10 @@ load_user_special_dirs (void)
d[len - 1] = 0;
if (is_relative)
- g_user_special_dirs[directory] = g_build_filename (g_get_home_dir (), d, NULL);
+ {
+ g_get_any_init ();
+ g_user_special_dirs[directory] = g_build_filename (g_home_dir, d, NULL);
+ }
else
g_user_special_dirs[directory] = g_strdup (d);
}