From: Franck Bui Date: Wed, 4 Aug 2021 09:20:07 +0000 (+0200) Subject: journalctl: never fail at flushing when the flushed flag is set X-Git-Tag: v250-rc1~671 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6fca35e642a112e80cc9bddb9a2b4805ad40df2;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 4a2343a63dd..73e4fafdffd 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"); }