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 4f413af2a0, 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.
This commit is contained in:
Franck Bui
2021-08-04 11:20:07 +02:00
committed by Lennart Poettering
parent e236711fd7
commit f6fca35e64

View File

@@ -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");
}