r = journal_file_data_payload(from, NULL, q, NULL, 0, 0, &data, &l);
if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) {
log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", i);
- continue;
+ goto next;
}
if (r < 0)
return r;
.hash = le64toh(u->data.hash),
};
+ next:
/* The above journal_file_data_payload() may clear or overwrite cached object. Hence, we need
* to re-read the object from the cache. */
r = journal_file_move_to_object(from, OBJECT_ENTRY, p, &o);
_public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **data, size_t *size) {
JournalFile *f;
size_t field_length;
- int r;
Object *o;
+ int r;
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
p = journal_file_entry_item_object_offset(f, o, i);
r = journal_file_data_payload(f, NULL, p, field, field_length, j->data_threshold, &d, &l);
if (r == 0)
- continue;
+ goto next;
if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) {
log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", i);
- continue;
+ goto next;
}
if (r < 0)
return r;
*size = l;
return 0;
+
+ next:
+ /* journal_file_data_payload() may clear or overwrite cached object. */
+ r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
+ if (r < 0)
+ return r;
}
return -ENOENT;
r = journal_file_data_payload(f, NULL, p, NULL, 0, j->data_threshold, &d, &l);
if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) {
log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", j->current_field);
- continue;
+ goto next;
}
if (r < 0)
return r;
j->current_field++;
return 1;
+
+ next:
+ /* journal_file_data_payload() may clear or overwrite cached object. */
+ r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
+ if (r < 0)
+ return r;
}
return 0;