[dconf/wip/reorg] user source: change approach to shm



commit 792a13279603b2533961a48b778514c805ef39cd
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Jul 8 19:07:23 2012 -0400

    user source: change approach to shm
    
    Use dconf_shm_is_flagged() instead of direct access.
    
    Change the semantics of what happens when we fail to open the shm file.
    We used to refuse to initialise at all in that case -- now we initialise
    but will try again every time to reopen ourselves.
    
    The error case will now be slower but closer to the correct behaviour.

 engine/dconf-engine-source-user.c |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)
---
diff --git a/engine/dconf-engine-source-user.c b/engine/dconf-engine-source-user.c
index 4f2d49b..3a2ddba 100644
--- a/engine/dconf-engine-source-user.c
+++ b/engine/dconf-engine-source-user.c
@@ -54,18 +54,12 @@ static gboolean
 dconf_engine_source_user_init (DConfEngineSource *source)
 {
   DConfEngineSourceUser *user_source = (DConfEngineSourceUser *) source;
-  guint8 *shm;
-
-  shm = dconf_shm_open (source->name);
-
-  if (shm == NULL)
-    return FALSE;
 
   source->bus_type = G_BUS_TYPE_SESSION;
   source->bus_name = g_strdup ("ca.desrt.dconf");
   source->object_path = g_strdup_printf ("/ca/desrt/dconf/Writer/%s", source->name);
   source->writable = TRUE;
-  user_source->shm = shm;
+  user_source->shm = dconf_shm_open (source->name);
 
   source->values = dconf_engine_source_user_open_gvdb (source->name);
 
@@ -77,7 +71,7 @@ dconf_engine_source_user_needs_reopen (DConfEngineSource *source)
 {
   DConfEngineSourceUser *user_source = (DConfEngineSourceUser *) source;
 
-  return user_source->shm && *user_source->shm;
+  return dconf_shm_is_flagged (user_source->shm);
 }
 
 static GvdbTable *
@@ -88,10 +82,7 @@ dconf_engine_source_user_reopen (DConfEngineSource *source)
   dconf_shm_close (user_source->shm);
   user_source->shm = dconf_shm_open (source->name);
 
-  if (user_source->shm)
-    return dconf_engine_source_user_open_gvdb (source->name);
-
-  return NULL;
+  return dconf_engine_source_user_open_gvdb (source->name);
 }
 
 static void



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