diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-03-06 02:42:32 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-03-06 02:42:32 +0100 |
commit | 48496df65c3ad1e3ad055d2b4632da7b73211715 (patch) | |
tree | 58910db8be71fd48811c27ce8af75414c25c49fb /src/journal/journal-file.c | |
parent | 85eda5721f8d2a20482ef228d341fbbd134c6799 (diff) |
journal: make sure to refresh window position and pointer after we linked up a data object
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r-- | src/journal/journal-file.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 90aa27e404..8c17620ed3 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -581,6 +581,8 @@ static int journal_file_link_data(JournalFile *f, Object *o, uint64_t offset, ui assert(offset > 0); assert(o->object.type == OBJECT_DATA); + /* This might alter the window we are looking at */ + o->data.next_hash_offset = o->data.next_field_offset = 0; o->data.entry_offset = o->data.entry_array_offset = 0; o->data.n_entries = 0; @@ -591,18 +593,14 @@ static int journal_file_link_data(JournalFile *f, Object *o, uint64_t offset, ui /* Only entry in the hash table is easy */ f->data_hash_table[h].head_hash_offset = htole64(offset); } else { - /* Temporarily move back to the previous data object, - * to patch in pointer */ + /* Move back to the previous data object, to patch in + * pointer */ r = journal_file_move_to_object(f, OBJECT_DATA, p, &o); if (r < 0) return r; o->data.next_hash_offset = htole64(offset); - - r = journal_file_move_to_object(f, OBJECT_DATA, offset, &o); - if (r < 0) - return r; } f->data_hash_table[h].tail_hash_offset = htole64(offset); @@ -614,6 +612,7 @@ int journal_file_find_data_object_with_hash( JournalFile *f, const void *data, uint64_t size, uint64_t hash, Object **ret, uint64_t *offset) { + uint64_t p, osize, h; int r; @@ -702,7 +701,11 @@ int journal_file_find_data_object( ret, offset); } -static int journal_file_append_data(JournalFile *f, const void *data, uint64_t size, Object **ret, uint64_t *offset) { +static int journal_file_append_data( + JournalFile *f, + const void *data, uint64_t size, + Object **ret, uint64_t *offset) { + uint64_t hash, p; uint64_t osize; Object *o; @@ -760,6 +763,12 @@ static int journal_file_append_data(JournalFile *f, const void *data, uint64_t s if (r < 0) return r; + /* The linking might have altered the window, so let's + * refresh our pointer */ + r = journal_file_move_to_object(f, OBJECT_DATA, p, &o); + if (r < 0) + return r; + if (ret) *ret = o; |