[dconf/wip/proxy: 8/12] engine: rework initial value for has_locks



commit b0995c810c4eee20c0a1e572f7a18e617a3bdef5
Author: Allison Lortie <desrt desrt ca>
Date:   Sun Oct 16 10:41:03 2016 +0200

    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.

 engine/dconf-engine.c |   12 ++++++------
 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);


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