summaryrefslogtreecommitdiff
path: root/src/journal/sd-journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r--src/journal/sd-journal.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 3aa9ed4b32..4c4cc2d21c 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -102,7 +102,8 @@ static void init_location(Location *l, LocationType type, JournalFile *f, Object
l->seqnum_set = l->realtime_set = l->monotonic_set = l->xor_hash_set = true;
}
-static void set_location(sd_journal *j, LocationType type, JournalFile *f, Object *o, uint64_t offset) {
+static void set_location(sd_journal *j, LocationType type, JournalFile *f, Object *o,
+ direction_t direction, uint64_t offset) {
assert(j);
assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK);
assert(f);
@@ -110,12 +111,10 @@ static void set_location(sd_journal *j, LocationType type, JournalFile *f, Objec
init_location(&j->current_location, type, f, o);
- if (j->current_file)
- j->current_file->current_offset = 0;
-
j->current_file = f;
j->current_field = 0;
+ f->last_direction = direction;
f->current_offset = offset;
}
@@ -811,7 +810,7 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
assert(j);
assert(f);
- if (f->current_offset > 0) {
+ if (f->last_direction == direction && f->current_offset > 0) {
cp = f->current_offset;
r = journal_file_move_to_object(f, OBJECT_ENTRY, cp, &c);
@@ -908,7 +907,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
if (r < 0)
return r;
- set_location(j, LOCATION_DISCRETE, new_file, o, new_offset);
+ set_location(j, LOCATION_DISCRETE, new_file, o, direction, new_offset);
return 1;
}