anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0517-journal-add-use-flushed_flag_is_set-helper-4041.patch

dd65c9
From 0adc312bbf5ea8ea654a5a4740f78f37eda2e9d3 Mon Sep 17 00:00:00 2001
dd65c9
From: Vito Caputo <vcaputo@gnugeneration.com>
dd65c9
Date: Thu, 17 Aug 2017 09:45:38 +0200
dd65c9
Subject: [PATCH] journal: add/use flushed_flag_is_set() helper (#4041)
dd65c9
dd65c9
Minor cleanup suggested by Lennart.
dd65c9
dd65c9
(cherry-picked from commit 6431c7e216ceb9f3cfe073c94a47ac413b892e55)
dd65c9
dd65c9
Related: #1364092
dd65c9
---
dd65c9
 src/journal/journald-server.c | 6 ++++--
dd65c9
 1 file changed, 4 insertions(+), 2 deletions(-)
dd65c9
dd65c9
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
c62b8e
index 3e9412d577..96ffda4ec9 100644
dd65c9
--- a/src/journal/journald-server.c
dd65c9
+++ b/src/journal/journald-server.c
dd65c9
@@ -917,6 +917,9 @@ finish:
dd65c9
         dispatch_message_real(s, iovec, n, m, ucred, tv, label, label_len, unit_id, priority, object_pid);
dd65c9
 }
dd65c9
 
dd65c9
+static bool flushed_flag_is_set(void) {
dd65c9
+        return (access("/run/systemd/journal/flushed", F_OK) >= 0);
dd65c9
+}
dd65c9
 
dd65c9
 static int system_journal_open(Server *s, bool flush_requested) {
dd65c9
         int r;
dd65c9
@@ -933,8 +936,7 @@ static int system_journal_open(Server *s, bool flush_requested) {
dd65c9
 
dd65c9
         if (!s->system_journal &&
dd65c9
             (s->storage == STORAGE_PERSISTENT || s->storage == STORAGE_AUTO) &&
dd65c9
-            (flush_requested
dd65c9
-             || (flushed = (access("/run/systemd/journal/flushed", F_OK) >= 0)))) {
dd65c9
+            (flush_requested || (flushed = flushed_flag_is_set()))) {
dd65c9
 
dd65c9
                 /* If in auto mode: first try to create the machine
dd65c9
                  * path, but not the prefix.