[dconf/wip/reorg: 493/523] user source: use threadsafe init for shmdir
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf/wip/reorg: 493/523] user source: use threadsafe init for shmdir
- Date: Mon, 9 Jul 2012 02:48:49 +0000 (UTC)
commit fb6ad83ace3aa4c7fb912b202754161ae8c1da65
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Jul 6 14:06:04 2012 -0400
user source: use threadsafe init for shmdir
Otherwise it's possible for multiple threads to initialise it at the
same time.
Each thread will come up with the same value anyway, but it's a string,
so we will leak all but one of them.
engine/dconf-engine-source-user.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/engine/dconf-engine-source-user.c b/engine/dconf-engine-source-user.c
index dba655f..7c44b79 100644
--- a/engine/dconf-engine-source-user.c
+++ b/engine/dconf-engine-source-user.c
@@ -41,8 +41,8 @@ dconf_engine_source_user_open_shm (const gchar *name)
void *memory;
gint fd;
- if (shmdir == NULL)
- shmdir = g_build_filename (g_get_user_runtime_dir (), "dconf", NULL);
+ if (g_once_init_enter (&shmdir))
+ g_once_init_leave (&shmdir, g_build_filename (g_get_user_runtime_dir (), "dconf", NULL));
filename = g_build_filename (shmdir, name, NULL);
memory = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]