teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0904-journald-server-always-touch-state-file-in-signal-ha.patch

6f381c
From 980add7d84084a474c6c604c0670743c2d1e624c Mon Sep 17 00:00:00 2001
6f381c
From: David Tardon <dtardon@redhat.com>
6f381c
Date: Mon, 13 Mar 2023 14:32:20 +0100
6f381c
Subject: [PATCH] journald-server: always touch state file in signal handler
6f381c
6f381c
`journalctl --relinquish-var` waits on that file, so we must create if
6f381c
even if nothing has really happened.
6f381c
6f381c
RHEL-only
6f381c
6f381c
Related: #2174645
6f381c
---
6f381c
 src/journal/journald-server.c | 12 +++++++-----
6f381c
 1 file changed, 7 insertions(+), 5 deletions(-)
6f381c
6f381c
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
6f381c
index aa70db95cc..4788ff78bb 100644
6f381c
--- a/src/journal/journald-server.c
6f381c
+++ b/src/journal/journald-server.c
6f381c
@@ -1259,8 +1259,6 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo
6f381c
 }
6f381c
 
6f381c
 static void relinquish_var(Server *s) {
6f381c
-        int r;
6f381c
-
6f381c
         assert(s);
6f381c
 
6f381c
         if (s->storage == STORAGE_NONE)
6f381c
@@ -1278,15 +1276,15 @@ static void relinquish_var(Server *s) {
6f381c
         if (unlink("/run/systemd/journal/flushed") < 0 && errno != ENOENT)
6f381c
                 log_warning_errno(errno, "Failed to unlink /run/systemd/journal/flushed, ignoring: %m")  ;
6f381c
 
6f381c
-        r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC));
6f381c
-        if (r < 0)
6f381c
-                log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
6f381c
+        /* NOTE: We don't create our own state file here, because dispatch_sigrtmin2() has to do it anyway.
6f381c
+         * But if this function is ever called from another place, the creation must be done here too. */
6f381c
 
6f381c
         return;
6f381c
 }
6f381c
 
6f381c
 static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
6f381c
         Server *s = userdata;
6f381c
+        int r;
6f381c
 
6f381c
         assert(s);
6f381c
         assert(si);
6f381c
@@ -1295,6 +1293,10 @@ static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo
6f381c
 
6f381c
         relinquish_var(s);
6f381c
 
6f381c
+        r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC));
6f381c
+        if (r < 0)
6f381c
+                log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
6f381c
+
6f381c
         return 0;
6f381c
 }
6f381c