summaryrefslogtreecommitdiff
path: root/src/journal/sd-journal.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-12-16 21:03:36 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-12-18 12:17:20 +0100
commit6573ef05a3cbe15949acfbbf1ad03726068907bd (patch)
treecb3d38ce419ba37de77b8cb358e82883573d8e22 /src/journal/sd-journal.c
parent1fc605b0e130149a44abfa38c33f4535cfe548ea (diff)
journal: keep per-JournalFile location info during iteration
In next_beyond_location() when we find a candidate entry in a journal file, save its location information in struct JournalFile. The purpose of remembering the locations of candidate entries is to be able to save work in the next iteration. This patch does only the remembering part. LOCATION_SEEK means the location identifies a candidate entry. When a winner is picked from among candidates, it becomes LOCATION_DISCRETE. LOCATION_TAIL here signifies we've iterated the file to the end (or the beginning in the case of reversed direction).
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r--src/journal/sd-journal.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index adaf402f46..71b056c234 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -128,6 +128,10 @@ static void set_location(sd_journal *j, LocationType type, JournalFile *f, Objec
f->last_direction = direction;
f->current_offset = offset;
+
+ /* Let f know its candidate entry was picked. */
+ assert(f->location_type == LOCATION_SEEK);
+ f->location_type = LOCATION_DISCRETE;
}
static int match_is_valid(const void *data, size_t size) {
@@ -855,6 +859,8 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
found = true;
if (found) {
+ journal_file_save_location(f, direction, c, cp);
+
if (ret)
*ret = c;
if (offset)
@@ -887,8 +893,10 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
log_debug_errno(r, "Can't iterate through %s, ignoring: %m", f->path);
remove_file_real(j, f);
continue;
- } else if (r == 0)
+ } else if (r == 0) {
+ f->location_type = LOCATION_TAIL;
continue;
+ }
if (!new_file)
found = true;