chiark / gitweb /
bus: stop using EDEADLOCK
[elogind.git] / src / journal / sd-journal.c
index ecf47fda3d36481d5426eb3c323fd5674a36b6e8..9b9e8ac8593e724f597802d3336651b96aa6773d 100644 (file)
@@ -24,7 +24,7 @@
 #include <stddef.h>
 #include <unistd.h>
 #include <sys/inotify.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <sys/vfs.h>
 #include <linux/magic.h>
 
@@ -723,13 +723,17 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
         assert(j);
         assert(f);
 
-        if (f->last_direction == direction && f->current_offset > 0) {
-                /* 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;
+        n_entries = le64toh(f->header->n_entries);
+
+        /* If we hit EOF before, we don't need to look into this file again
+         * unless direction changed or new entries appeared. */
+        if (f->last_direction == direction && 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) {
                 /* LOCATION_SEEK here means we did the work in a previous
                  * iteration and the current location already points to a
                  * candidate entry. */
@@ -738,14 +742,16 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
                         if (r <= 0)
                                 return r;
 
-                        journal_file_save_location(f, direction, c, cp);
+                        journal_file_save_location(f, c, cp);
                 }
         } else {
+                f->last_direction = direction;
+
                 r = find_location_with_matches(j, f, direction, &c, &cp);
                 if (r <= 0)
                         return r;
 
-                journal_file_save_location(f, direction, c, cp);
+                journal_file_save_location(f, c, cp);
         }
 
         /* OK, we found the spot, now let's advance until an entry
@@ -773,7 +779,7 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
                 if (r <= 0)
                         return r;
 
-                journal_file_save_location(f, direction, c, cp);
+                journal_file_save_location(f, c, cp);
         }
 }
 
@@ -1242,7 +1248,7 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
         r = add_any_file(j, path);
         if (r == -ENOENT)
                 return 0;
-        return 0;
+        return r;
 }
 
 static int remove_file(sd_journal *j, const char *prefix, const char *filename) {