X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fjournal%2Fsd-journal.c;h=0aaf2257d4c668640a151f0b5de15b8ff7cbd8a4;hp=8cf6de651e58481ea81583923b028c064d40cbc9;hb=6e693b42dcb0b332364b0414107826826925c49f;hpb=e499c9998bb42b792afb1acd3532fe975280c0fd diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 8cf6de651..0aaf2257d 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -727,14 +727,20 @@ static int next_with_matches( return next_for_match(j, j->level0, f, direction == DIRECTION_DOWN ? cp+1 : cp-1, direction, ret, offset); } -static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direction, Object **ret, uint64_t *offset) { +static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direction) { Object *c; - uint64_t cp; + uint64_t cp, n_entries; int r; assert(j); assert(f); + /* If we hit EOF before, recheck if any new entries arrived. */ + n_entries = le64toh(f->header->n_entries); + if (f->location_type == LOCATION_TAIL && n_entries == f->last_n_entries) + return 0; + f->last_n_entries = n_entries; + if (f->last_direction == direction && f->current_offset > 0) { cp = f->current_offset; @@ -771,11 +777,6 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc if (found) { journal_file_save_location(f, direction, c, cp); - - if (ret) - *ret = c; - if (offset) - *offset = cp; return 1; } @@ -787,7 +788,6 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc static int real_journal_next(sd_journal *j, direction_t direction) { JournalFile *f, *new_file = NULL; - uint64_t p = 0; Iterator i; Object *o; int r; @@ -798,7 +798,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) { ORDERED_HASHMAP_FOREACH(f, j->files, i) { bool found; - r = next_beyond_location(j, f, direction, &o, &p); + r = next_beyond_location(j, f, direction); if (r < 0) { log_debug_errno(r, "Can't iterate through %s, ignoring: %m", f->path); remove_file_real(j, f);