summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-03-06 02:42:32 +0100
committerTollef Fog Heen <tfheen@err.no>2012-03-07 08:18:28 +0100
commite2ea61e3a66c2e3053c263f2835a8fc0677abee8 (patch)
treef3a676ce60ea2ca6be24e4fc5044dd2fccb97503
parent2b788757f391d18572313a64a66bd7e11f1fb034 (diff)
downloadsystemd-e2ea61e3a66c2e3053c263f2835a8fc0677abee8.tar.gz
journal: make sure to refresh window position and pointer after we linked up a data object
-rw-r--r--src/journal/journal-file.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 20ca3f61cb..7514dd8351 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;