sd-journal: make sure it's safe to call sd_journal_process() before the first sd_jour...
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2018 21:38:46 +0000 (22:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 12 Feb 2018 10:27:12 +0000 (11:27 +0100)
In that case we have no inotify fd yet, and there's nothing to process
hence. Let's make the call a NOP.

(Previously, without this change we'd end up trying to read off inotify
fd -1, which is quite a problem... ðŸ˜¢)

src/journal/sd-journal.c

index 221c51e..4deee46 100644 (file)
@@ -2540,6 +2540,9 @@ _public_ int sd_journal_process(sd_journal *j) {
         assert_return(j, -EINVAL);
         assert_return(!journal_pid_changed(j), -ECHILD);
 
+        if (j->inotify_fd < 0) /* We have no inotify fd yet? Then there's noting to process. */
+                return 0;
+
         j->last_process_usec = now(CLOCK_MONOTONIC);
         j->last_invalidate_counter = j->current_invalidate_counter;