[dconf] many writer fixes:



commit 2a3113a9c265b253d7539155e9434220ddc58fb0
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Aug 19 12:59:25 2009 -0400

    many writer fixes:
    
      - create valid size file (100 is not a multiple of 8)
      - don't sync inside merge() -- that's why we have sync()
      - use indirect lookup for root index on flatten() so that we
        get the latest changes included in our flattened tree
      - add a little debugging to the rebuild process
      - fix a reversed assertion

 writer/dconf-writer-file.c    |    5 ++++-
 writer/dconf-writer-flatten.c |   14 +++++++++++---
 writer/dconf-writer-merge.c   |    8 --------
 writer/dconf-writer.c         |    2 +-
 4 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/writer/dconf-writer-file.c b/writer/dconf-writer-file.c
index c1b914e..bc566b2 100644
--- a/writer/dconf-writer-file.c
+++ b/writer/dconf-writer-file.c
@@ -171,7 +171,7 @@ dconf_writer_create (DConfWriter  *writer,
     return FALSE;
 
   bytes = blocks * sizeof (struct chunk_header);
-  bytes += 100;
+  bytes += 80;
 
   if ((contents = dconf_writer_create_temp_file (writer->filename,
                                                  &writer->fd, bytes,
@@ -369,6 +369,9 @@ dconf_writer_sync (DConfWriter  *writer,
       gsize previous_size;
       gboolean success;
 
+      g_message ("Doing rebuild now.");
+      dconf_writer_dump (writer);
+
       /* store the information we need */
       previous_contents = dconf_writer_flatten (writer);
       previous_super = writer->data.super;
diff --git a/writer/dconf-writer-flatten.c b/writer/dconf-writer-flatten.c
index 8af52bf..9f4c58a 100644
--- a/writer/dconf-writer-flatten.c
+++ b/writer/dconf-writer-flatten.c
@@ -86,13 +86,17 @@ dconf_writer_flatten_index (DConfWriter *writer,
 GTree *
 dconf_writer_flatten (DConfWriter *writer)
 {
+  guint32 root_index;
   GTree *tree;
 
   tree = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
                           g_free, (GDestroyNotify) g_variant_unref);
 
-  dconf_writer_flatten_index (writer, tree, "", 0,
-                              writer->data.super->root_index);
+  root_index = dconf_writer_get_index (writer,
+                                       &writer->data.super->root_index,
+                                       TRUE);
+
+  dconf_writer_flatten_index (writer, tree, "", 0, root_index);
 
   return tree;
 }
@@ -163,8 +167,12 @@ dconf_writer_measure_entry (gpointer key,
    */
   if (! (/*atomic*/0))
     {
+      GVariant *variant;
+
+      variant = g_variant_ref_sink (g_variant_new_variant (value));
       mts->blocks += sizeof (struct chunk_header) / 8;
-      mts->blocks += (g_variant_get_size (value) + 7) / 8;
+      mts->blocks += (g_variant_get_size (variant) + 7) / 8;
+      g_variant_unref (variant);
     }
 
   mts->blocks += sizeof (struct dir_entry) / 8;
diff --git a/writer/dconf-writer-merge.c b/writer/dconf-writer-merge.c
index 41df246..7550382 100644
--- a/writer/dconf-writer-merge.c
+++ b/writer/dconf-writer-merge.c
@@ -678,12 +678,4 @@ dconf_writer_merge (DConfWriter  *writer,
   dconf_writer_merge_index (writer, &index, prefix,
                             names, values, n_items, FALSE);
   dconf_writer_set_index (writer, &super->root_index, index, FALSE);
-
-  if (writer->changed_pointer)
-    {
-      *writer->changed_pointer = writer->changed_value;
-      writer->changed_pointer = NULL;
-    }
-  else
-    g_assert (n_items == 1);
 }
diff --git a/writer/dconf-writer.c b/writer/dconf-writer.c
index 503621e..e97b5ce 100644
--- a/writer/dconf-writer.c
+++ b/writer/dconf-writer.c
@@ -194,7 +194,7 @@ dconf_writer_get_index (DConfWriter            *writer,
   /* if we already have a changed pointer then this means that we have
    * (theoretically) visible changes.  so why are we doing more work?
    */
-  g_assert (!for_copy || !writer->changed_pointer);
+  g_assert (for_copy || !writer->changed_pointer);
 
   if G_UNLIKELY (writer->changed_pointer == pointer)
     return writer->changed_value;



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