systemd/backport-journalctl-never-fail-at-flushing-when-the-flushed-f.patch
xujing 826fd825d6 sync and backport some patches
systemd-journald: Fix journal file descriptors leak problems.
systemd: Activation service must be restarted when it is already started and re-actived by dbus
systemd-core: fix problem of dbus service can not be started
systemd-core: Delay to restart when a service can not be auto-restarted when there is one STOP_JOB for the service
core: fix SIGABRT on empty exec command argv
journalctl: never fail at flushing when the flushed flag is set
timesync: fix wrong type for receiving timestamp in nanoseconds
udev: fix potential memleak
(cherry picked from commit d0907552a565ed01a4f9da4dd27168b3726f9236)
2022-03-30 10:15:27 +08:00

40 lines
1.4 KiB
Diff

From f6fca35e642a112e80cc9bddb9a2b4805ad40df2 Mon Sep 17 00:00:00 2001
From: Franck Bui <fbui@suse.com>
Date: Wed, 4 Aug 2021 11:20:07 +0200
Subject: [PATCH] journalctl: never fail at flushing when the flushed flag is
set
Even if journald was not running, flushing the volatile journal used to work if
the journal was already flushed (ie the flushed flag
/run/systemd/journald/flushed was created).
However since commit 4f413af2a0a, this behavior changed and now '--flush' fails
because it tries to contact journald without checking the presence of the
flushed flag anymore.
This patch restores the previous behavior since there's no reason to fail when
journalctl can figure out that the flush is not necessary.
---
src/journal/journalctl.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 4a2343a63d..73e4fafdff 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -2064,6 +2064,11 @@ static int simple_varlink_call(const char *option, const char *method) {
}
static int flush_to_var(void) {
+ if (access("/run/systemd/journal/flushed", F_OK) >= 0)
+ return 0; /* Already flushed, no need to contact journald */
+ if (errno != ENOENT)
+ return log_error_errno(errno, "Unable to check for existence of /run/systemd/journal/flushed: %m");
+
return simple_varlink_call("--flush", "io.systemd.Journal.FlushToVar");
}
--
2.27.0