dd65c9
From efd523764efcd39340fb62875716c8c8b79f0de9 Mon Sep 17 00:00:00 2001
de541a
From: Lennart Poettering <lennart@poettering.net>
de541a
Date: Fri, 9 Feb 2018 22:38:46 +0100
de541a
Subject: [PATCH] sd-journal: make sure it's safe to call sd_journal_process()
de541a
 before the first sd_journal_wait()
de541a
MIME-Version: 1.0
de541a
Content-Type: text/plain; charset=UTF-8
de541a
Content-Transfer-Encoding: 8bit
de541a
de541a
In that case we have no inotify fd yet, and there's nothing to process
de541a
hence. Let's make the call a NOP.
de541a
de541a
(Previously, without this change we'd end up trying to read off inotify
de541a
fd -1, which is quite a problem... 😢)
de541a
de541a
(cherry picked from commit 10c4d6405f74258ea4fac5db4888c1bf49ad5399)
de541a
de541a
Related: #1540538
de541a
---
de541a
 src/journal/sd-journal.c | 3 +++
de541a
 1 file changed, 3 insertions(+)
de541a
de541a
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
de541a
index 9186f5188..e1cde6e1c 100644
de541a
--- a/src/journal/sd-journal.c
de541a
+++ b/src/journal/sd-journal.c
de541a
@@ -2329,6 +2329,9 @@ _public_ int sd_journal_process(sd_journal *j) {
de541a
         assert_return(j, -EINVAL);
de541a
         assert_return(!journal_pid_changed(j), -ECHILD);
de541a
 
de541a
+        if (j->inotify_fd < 0) /* We have no inotify fd yet? Then there's noting to process. */
de541a
+                return 0;
de541a
+
de541a
         j->last_process_usec = now(CLOCK_MONOTONIC);
de541a
         j->last_invalidate_counter = j->current_invalidate_counter;
de541a