summaryrefslogtreecommitdiff
path: root/metadata/metatree.c
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2014-08-29 10:46:25 +0200
committerOndrej Holy <oholy@redhat.com>2014-09-05 13:56:22 +0200
commite8d04b3d286745534f0a07e57e17f5142eee6007 (patch)
treebc529d0b8aed09943eaddcb7aa7c01114164cf2a /metadata/metatree.c
parentd5e07fe5491edd2f9cfc6dfe271209d888f2ba49 (diff)
downloadgvfs-e8d04b3d286745534f0a07e57e17f5142eee6007.tar.gz
metatree: avoid endless looping when the entry is too large
When an application tries to save a larger key-value pair than the size of the journal, it triggers the journal to be flushed to make space for the entry and the operation is then retried, but it never fits, and the loop continues forever. This patch removes the endless retry loop and retries the operation only once after the flush. We know that there isn't enough space for the entry if it fails after the flush. https://bugzilla.gnome.org/show_bug.cgi?id=637095
Diffstat (limited to 'metadata/metatree.c')
-rw-r--r--metadata/metatree.c65
1 files changed, 45 insertions, 20 deletions
diff --git a/metadata/metatree.c b/metadata/metatree.c
index 43766c83..7b59c4a5 100644
--- a/metadata/metatree.c
+++ b/metadata/metatree.c
@@ -2361,13 +2361,18 @@ meta_tree_unset (MetaTree *tree,
entry = meta_journal_entry_new_unset (mtime, path, key);
res = TRUE;
- retry:
if (!meta_journal_add_entry (tree->journal, entry))
{
if (meta_tree_flush_locked (tree))
- goto retry;
-
- res = FALSE;
+ {
+ if (!meta_journal_add_entry (tree->journal, entry))
+ {
+ g_warning ("meta_tree_unset: entry is bigger then the size of journal\n");
+ res = FALSE;
+ }
+ }
+ else
+ res = FALSE;
}
g_string_free (entry, TRUE);
@@ -2401,13 +2406,18 @@ meta_tree_set_string (MetaTree *tree,
entry = meta_journal_entry_new_set (mtime, path, key, value);
res = TRUE;
- retry:
if (!meta_journal_add_entry (tree->journal, entry))
{
if (meta_tree_flush_locked (tree))
- goto retry;
-
- res = FALSE;
+ {
+ if (!meta_journal_add_entry (tree->journal, entry))
+ {
+ g_warning ("meta_tree_set_string: entry is bigger then the size of journal\n");
+ res = FALSE;
+ }
+ }
+ else
+ res = FALSE;
}
g_string_free (entry, TRUE);
@@ -2441,13 +2451,18 @@ meta_tree_set_stringv (MetaTree *tree,
entry = meta_journal_entry_new_setv (mtime, path, key, value);
res = TRUE;
- retry:
if (!meta_journal_add_entry (tree->journal, entry))
{
if (meta_tree_flush_locked (tree))
- goto retry;
-
- res = FALSE;
+ {
+ if (!meta_journal_add_entry (tree->journal, entry))
+ {
+ g_warning ("meta_tree_set_stringv: entry is bigger then the size of journal\n");
+ res = FALSE;
+ }
+ }
+ else
+ res = FALSE;
}
g_string_free (entry, TRUE);
@@ -2479,13 +2494,18 @@ meta_tree_remove (MetaTree *tree,
entry = meta_journal_entry_new_remove (mtime, path);
res = TRUE;
- retry:
if (!meta_journal_add_entry (tree->journal, entry))
{
if (meta_tree_flush_locked (tree))
- goto retry;
-
- res = FALSE;
+ {
+ if (!meta_journal_add_entry (tree->journal, entry))
+ {
+ g_warning ("meta_tree_remove: entry is bigger then the size of journal\n");
+ res = FALSE;
+ }
+ }
+ else
+ res = FALSE;
}
g_string_free (entry, TRUE);
@@ -2518,13 +2538,18 @@ meta_tree_copy (MetaTree *tree,
entry = meta_journal_entry_new_copy (mtime, src, dest);
res = TRUE;
- retry:
if (!meta_journal_add_entry (tree->journal, entry))
{
if (meta_tree_flush_locked (tree))
- goto retry;
-
- res = FALSE;
+ {
+ if (!meta_journal_add_entry (tree->journal, entry))
+ {
+ g_warning ("meta_tree_copy: entry is bigger then the size of journal\n");
+ res = FALSE;
+ }
+ }
+ else
+ res = FALSE;
}
g_string_free (entry, TRUE);