summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllison Lortie <desrt@desrt.ca>2016-10-16 10:41:03 +0200
committerAllison Lortie <desrt@desrt.ca>2016-10-16 10:41:03 +0200
commitb0995c810c4eee20c0a1e572f7a18e617a3bdef5 (patch)
treee95d80f76e37b7287bc34341672cbf4523cd37c4
parent3ceff8a9ef70a71f236d56afe92067d81d05c16e (diff)
downloaddconf-b0995c810c4eee20c0a1e572f7a18e617a3bdef5.tar.gz
engine: rework initial value for has_locks
In the case that the user database file does not exist on disk, "re"opening it for the first time will fail, causing the refresh function to return FALSE. This means that we will not end up recomputing the value of has_locks as was previously assumed. To avoid this problem, we fill in the proper value from the start, instead of guessing.
-rw-r--r--engine/dconf-engine.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index 251974a..9e4b358 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -254,18 +254,18 @@ dconf_engine_new (const gchar *profile,
engine->free_func = free_func;
engine->ref_count = 1;
- /* The engine starts with zero sources, which means that every key is
- * effectively locked. If the engine has more than zero sources, this
- * will be updated when the first refresh is done.
- */
- engine->has_locks = TRUE;
-
g_mutex_init (&engine->sources_lock);
g_mutex_init (&engine->queue_lock);
g_cond_init (&engine->queue_cond);
engine->sources = dconf_engine_profile_open (profile, &engine->n_sources);
+ /* We need to provide a reasonable initial value here. We do not
+ * inspect the sources themselves for having locks, because this will
+ * be done the first time the engine is acquired.
+ */
+ engine->has_locks = engine->n_sources == 0 || !engine->sources[0]->writable;
+
g_mutex_lock (&dconf_engine_global_lock);
dconf_engine_global_list = g_slist_prepend (dconf_engine_global_list, engine);
g_mutex_unlock (&dconf_engine_global_lock);