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

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