chiark / gitweb /
journald: be a bit more verbose
[elogind.git] / src / journal / sd-journal.c
index 05c0d96ce180165f225a872398090e2366e09660..86ac267de406550074dd5065269586f19ea86dfc 100644 (file)
@@ -66,7 +66,7 @@ static void init_location(Location *l, JournalFile *f, Object *o) {
         l->seqnum_id = f->header->seqnum_id;
         l->realtime = le64toh(o->entry.realtime);
         l->monotonic = le64toh(o->entry.monotonic);
-        l->boot_id = le64toh(o->entry.boot_id);
+        l->boot_id = o->entry.boot_id;
         l->xor_hash = le64toh(o->entry.xor_hash);
 
         l->seqnum_set = l->realtime_set = l->monotonic_set = l->xor_hash_set = true;
@@ -527,6 +527,9 @@ static int next_with_matches(sd_journal *j, JournalFile *f, direction_t directio
                          * matches are not OK */
 
                         r = journal_file_next_entry_for_data(f, c, cp, le64toh(c->entry.items[k].object_offset), direction, &qo, &q);
+                        /* This pointer is invalidated if the window was
+                         * remapped. May need to re-fetch it later */
+                        c = NULL;
                         if (r < 0)
                                 return r;
 
@@ -552,8 +555,15 @@ static int next_with_matches(sd_journal *j, JournalFile *f, direction_t directio
 
                 /* Did this entry match against all matches? */
                 if (found) {
-                        if (ret)
+                        if (ret) {
+                                if (c == NULL) {
+                                        /* Re-fetch the entry */
+                                        r = journal_file_move_to_object(f, OBJECT_ENTRY, cp, &c);
+                                        if (r < 0)
+                                                return r;
+                                }
                                 *ret = c;
+                        }
                         if (offset)
                                 *offset = cp;
                         return 1;
@@ -1298,7 +1308,7 @@ _public_ int sd_journal_get_monotonic_usec(sd_journal *j, uint64_t *ret, sd_id12
                         return r;
 
                 if (!sd_id128_equal(id, o->entry.boot_id))
-                        return -ENOENT;
+                        return -ESTALE;
         }
 
         *ret = le64toh(o->entry.monotonic);
@@ -1590,27 +1600,27 @@ _public_ int sd_journal_process(sd_journal *j) {
         }
 }
 
-_public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
-        if (!j)
-                return -EINVAL;
-        if (!field)
-                return -EINVAL;
-
-        return -ENOTSUP;
-}
-
-_public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l) {
-        if (!j)
-                return -EINVAL;
-        if (!data)
-                return -EINVAL;
-        if (!l)
-                return -EINVAL;
-
-        return -ENOTSUP;
-}
-
-_public_ void sd_journal_restart_unique(sd_journal *j) {
-        if (!j)
-                return;
-}
+/* _public_ int sd_journal_query_unique(sd_journal *j, const char *field) { */
+/*         if (!j) */
+/*                 return -EINVAL; */
+/*         if (!field) */
+/*                 return -EINVAL; */
+
+/*         return -ENOTSUP; */
+/* } */
+
+/* _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l) { */
+/*         if (!j) */
+/*                 return -EINVAL; */
+/*         if (!data) */
+/*                 return -EINVAL; */
+/*         if (!l) */
+/*                 return -EINVAL; */
+
+/*         return -ENOTSUP; */
+/* } */
+
+/* _public_ void sd_journal_restart_unique(sd_journal *j) { */
+/*         if (!j) */
+/*                 return; */
+/* } */