teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0611-sd-journal-make-sure-it-s-safe-to-call-sd_journal_pr.patch

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