Blame SOURCES/gvfs-1.21.92-metatree-avoid-endless-looping-when-the-entry-is-too.patch

5b6909
From 46474abab3ff89a34cbe7fd7eb1ceba50d83d331 Mon Sep 17 00:00:00 2001
5b6909
From: Ondrej Holy <oholy@redhat.com>
5b6909
Date: Fri, 29 Aug 2014 10:46:25 +0200
5b6909
Subject: [PATCH] metatree: avoid endless looping when the entry is too large
5b6909
5b6909
When an application tries to save a larger key-value pair than the size
5b6909
of the journal, it triggers the journal to be flushed to make space for
5b6909
the entry and the operation is then retried, but it never fits, and the
5b6909
loop continues forever.
5b6909
5b6909
This patch removes the endless retry loop and retries the operation
5b6909
only once after the flush. We know that there isn't enough space for
5b6909
the entry if it fails after the flush.
5b6909
5b6909
https://bugzilla.gnome.org/show_bug.cgi?id=637095
5b6909
---
5b6909
 metadata/metatree.c | 65 ++++++++++++++++++++++++++++++++++++-----------------
5b6909
 1 file changed, 45 insertions(+), 20 deletions(-)
5b6909
5b6909
diff --git a/metadata/metatree.c b/metadata/metatree.c
5b6909
index 43766c8..7b59c4a 100644
5b6909
--- a/metadata/metatree.c
5b6909
+++ b/metadata/metatree.c
5b6909
@@ -2361,13 +2361,18 @@ meta_tree_unset (MetaTree                         *tree,
5b6909
   entry = meta_journal_entry_new_unset (mtime, path, key);
5b6909
 
5b6909
   res = TRUE;
5b6909
- retry:
5b6909
   if (!meta_journal_add_entry (tree->journal, entry))
5b6909
     {
5b6909
       if (meta_tree_flush_locked (tree))
5b6909
-	goto retry;
5b6909
-
5b6909
-      res = FALSE;
5b6909
+        {
5b6909
+	  if (!meta_journal_add_entry (tree->journal, entry))
5b6909
+	  {
5b6909
+	    g_warning ("meta_tree_unset: entry is bigger then the size of journal\n");
5b6909
+	    res = FALSE;
5b6909
+	  }
5b6909
+	}
5b6909
+      else
5b6909
+        res = FALSE;
5b6909
     }
5b6909
 
5b6909
   g_string_free (entry, TRUE);
5b6909
@@ -2401,13 +2406,18 @@ meta_tree_set_string (MetaTree                         *tree,
5b6909
   entry = meta_journal_entry_new_set (mtime, path, key, value);
5b6909
 
5b6909
   res = TRUE;
5b6909
- retry:
5b6909
   if (!meta_journal_add_entry (tree->journal, entry))
5b6909
     {
5b6909
       if (meta_tree_flush_locked (tree))
5b6909
-	goto retry;
5b6909
-
5b6909
-      res = FALSE;
5b6909
+        {
5b6909
+	  if (!meta_journal_add_entry (tree->journal, entry))
5b6909
+	  {
5b6909
+	    g_warning ("meta_tree_set_string: entry is bigger then the size of journal\n");
5b6909
+	    res = FALSE;
5b6909
+	  }
5b6909
+	}
5b6909
+      else
5b6909
+        res = FALSE;
5b6909
     }
5b6909
 
5b6909
   g_string_free (entry, TRUE);
5b6909
@@ -2441,13 +2451,18 @@ meta_tree_set_stringv (MetaTree                         *tree,
5b6909
   entry = meta_journal_entry_new_setv (mtime, path, key, value);
5b6909
 
5b6909
   res = TRUE;
5b6909
- retry:
5b6909
   if (!meta_journal_add_entry (tree->journal, entry))
5b6909
     {
5b6909
       if (meta_tree_flush_locked (tree))
5b6909
-	goto retry;
5b6909
-
5b6909
-      res = FALSE;
5b6909
+        {
5b6909
+	  if (!meta_journal_add_entry (tree->journal, entry))
5b6909
+	  {
5b6909
+	    g_warning ("meta_tree_set_stringv: entry is bigger then the size of journal\n");
5b6909
+	    res = FALSE;
5b6909
+	  }
5b6909
+	}
5b6909
+      else
5b6909
+        res = FALSE;
5b6909
     }
5b6909
 
5b6909
   g_string_free (entry, TRUE);
5b6909
@@ -2479,13 +2494,18 @@ meta_tree_remove (MetaTree *tree,
5b6909
   entry = meta_journal_entry_new_remove (mtime, path);
5b6909
 
5b6909
   res = TRUE;
5b6909
- retry:
5b6909
   if (!meta_journal_add_entry (tree->journal, entry))
5b6909
     {
5b6909
       if (meta_tree_flush_locked (tree))
5b6909
-	goto retry;
5b6909
-
5b6909
-      res = FALSE;
5b6909
+        {
5b6909
+	  if (!meta_journal_add_entry (tree->journal, entry))
5b6909
+	  {
5b6909
+	    g_warning ("meta_tree_remove: entry is bigger then the size of journal\n");
5b6909
+	    res = FALSE;
5b6909
+	  }
5b6909
+	}
5b6909
+      else
5b6909
+        res = FALSE;
5b6909
     }
5b6909
 
5b6909
   g_string_free (entry, TRUE);
5b6909
@@ -2518,13 +2538,18 @@ meta_tree_copy (MetaTree                         *tree,
5b6909
   entry = meta_journal_entry_new_copy (mtime, src, dest);
5b6909
 
5b6909
   res = TRUE;
5b6909
- retry:
5b6909
   if (!meta_journal_add_entry (tree->journal, entry))
5b6909
     {
5b6909
       if (meta_tree_flush_locked (tree))
5b6909
-	goto retry;
5b6909
-
5b6909
-      res = FALSE;
5b6909
+        {
5b6909
+	  if (!meta_journal_add_entry (tree->journal, entry))
5b6909
+	  {
5b6909
+	    g_warning ("meta_tree_copy: entry is bigger then the size of journal\n");
5b6909
+	    res = FALSE;
5b6909
+	  }
5b6909
+	}
5b6909
+      else
5b6909
+        res = FALSE;
5b6909
     }
5b6909
 
5b6909
   g_string_free (entry, TRUE);
5b6909
-- 
5b6909
1.9.3
5b6909