mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
journal: fix matches
This commit is contained in:
parent
50f20cfdb0
commit
466ccd92e2
@ -1434,7 +1434,7 @@ int journal_file_next_entry_for_data(
|
|||||||
assert(p > 0 || !o);
|
assert(p > 0 || !o);
|
||||||
|
|
||||||
r = journal_file_move_to_object(f, OBJECT_DATA, data_offset, &d);
|
r = journal_file_move_to_object(f, OBJECT_DATA, data_offset, &d);
|
||||||
if (r <= 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
n = le64toh(d->data.n_entries);
|
n = le64toh(d->data.n_entries);
|
||||||
|
@ -525,6 +525,7 @@ static int next_with_matches(sd_journal *j, JournalFile *f, direction_t directio
|
|||||||
uint64_t np, n;
|
uint64_t np, n;
|
||||||
bool found, term_result = false;
|
bool found, term_result = false;
|
||||||
Match *m, *term_match = NULL;
|
Match *m, *term_match = NULL;
|
||||||
|
Object *npo = NULL;
|
||||||
|
|
||||||
n = journal_file_entry_n_items(c);
|
n = journal_file_entry_n_items(c);
|
||||||
|
|
||||||
@ -535,6 +536,7 @@ static int next_with_matches(sd_journal *j, JournalFile *f, direction_t directio
|
|||||||
np = 0;
|
np = 0;
|
||||||
LIST_FOREACH(matches, m, j->matches) {
|
LIST_FOREACH(matches, m, j->matches) {
|
||||||
uint64_t q, k;
|
uint64_t q, k;
|
||||||
|
Object *qo = NULL;
|
||||||
|
|
||||||
/* Let's check if this is the beginning of a
|
/* Let's check if this is the beginning of a
|
||||||
* new term, i.e. has a different field prefix
|
* new term, i.e. has a different field prefix
|
||||||
@ -567,22 +569,26 @@ static int next_with_matches(sd_journal *j, JournalFile *f, direction_t directio
|
|||||||
* where we'd have to try next, in case the other
|
* where we'd have to try next, in case the other
|
||||||
* matches are not OK */
|
* matches are not OK */
|
||||||
|
|
||||||
r = journal_file_next_entry_for_data(f, c, cp, le64toh(c->entry.items[k].object_offset), direction, NULL, &q);
|
r = journal_file_next_entry_for_data(f, c, cp, le64toh(c->entry.items[k].object_offset), direction, &qo, &q);
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
|
|
||||||
if (direction == DIRECTION_DOWN) {
|
if (direction == DIRECTION_DOWN) {
|
||||||
if (q > np)
|
if (q > np) {
|
||||||
np = q;
|
np = q;
|
||||||
|
npo = qo;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (np == 0 || q < np)
|
if (np == 0 || q < np) {
|
||||||
np = q;
|
np = q;
|
||||||
|
npo = qo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the last term */
|
/* Check the last term */
|
||||||
if (term_match && term_result)
|
if (term_match && !term_result)
|
||||||
found = true;
|
found = false;
|
||||||
|
|
||||||
/* Did this entry match against all matches? */
|
/* Did this entry match against all matches? */
|
||||||
if (found) {
|
if (found) {
|
||||||
@ -600,6 +606,7 @@ static int next_with_matches(sd_journal *j, JournalFile *f, direction_t directio
|
|||||||
/* Hmm, ok, this entry only matched partially, so
|
/* Hmm, ok, this entry only matched partially, so
|
||||||
* let's try another one */
|
* let's try another one */
|
||||||
cp = np;
|
cp = np;
|
||||||
|
c = npo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,12 +619,12 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
|
|||||||
assert(f);
|
assert(f);
|
||||||
|
|
||||||
if (f->current_offset > 0) {
|
if (f->current_offset > 0) {
|
||||||
r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &c);
|
cp = f->current_offset;
|
||||||
|
|
||||||
|
r = journal_file_move_to_object(f, OBJECT_ENTRY, cp, &c);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
cp = f->current_offset;
|
|
||||||
|
|
||||||
r = next_with_matches(j, f, direction, &c, &cp);
|
r = next_with_matches(j, f, direction, &c, &cp);
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
return r;
|
return r;
|
||||||
|
Loading…
Reference in New Issue
Block a user