richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
0b2ce7
From 7a7b0c4ec7a5595a44d9c70d8270b0724a8b8c45 Mon Sep 17 00:00:00 2001
0b2ce7
From: David Tardon <dtardon@redhat.com>
0b2ce7
Date: Mon, 13 Mar 2023 14:31:38 +0100
0b2ce7
Subject: [PATCH] journald-server: move relinquish code into function
0b2ce7
0b2ce7
No functional change, just refactoring.
0b2ce7
0b2ce7
RHEL-only
0b2ce7
0b2ce7
Related: #2174645
0b2ce7
---
0b2ce7
 src/journal/journald-server.c | 23 ++++++++++++++++-------
0b2ce7
 1 file changed, 16 insertions(+), 7 deletions(-)
0b2ce7
0b2ce7
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
0b2ce7
index c72cb68095..aa70db95cc 100644
0b2ce7
--- a/src/journal/journald-server.c
0b2ce7
+++ b/src/journal/journald-server.c
0b2ce7
@@ -1258,20 +1258,16 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo
0b2ce7
         return 0;
0b2ce7
 }
0b2ce7
 
0b2ce7
-
0b2ce7
-static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
0b2ce7
-        Server *s = userdata;
0b2ce7
+static void relinquish_var(Server *s) {
0b2ce7
         int r;
0b2ce7
 
0b2ce7
         assert(s);
0b2ce7
 
0b2ce7
         if (s->storage == STORAGE_NONE)
0b2ce7
-                return 0;
0b2ce7
+                return;
0b2ce7
 
0b2ce7
         if (s->runtime_journal && !s->system_journal)
0b2ce7
-                return 0;
0b2ce7
-
0b2ce7
-        log_debug("Received request to relinquish /var from PID " PID_FMT, si->ssi_pid);
0b2ce7
+                return;
0b2ce7
 
0b2ce7
         (void) system_journal_open(s, false, true);
0b2ce7
 
0b2ce7
@@ -1286,6 +1282,19 @@ static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo
0b2ce7
         if (r < 0)
0b2ce7
                 log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
0b2ce7
 
0b2ce7
+        return;
0b2ce7
+}
0b2ce7
+
0b2ce7
+static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
0b2ce7
+        Server *s = userdata;
0b2ce7
+
0b2ce7
+        assert(s);
0b2ce7
+        assert(si);
0b2ce7
+
0b2ce7
+        log_debug("Received request to relinquish /var from PID " PID_FMT, si->ssi_pid);
0b2ce7
+
0b2ce7
+        relinquish_var(s);
0b2ce7
+
0b2ce7
         return 0;
0b2ce7
 }
0b2ce7