naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
b11b5f
From 708c394b7ca35fe2328fa0760696ff95caab8ff8 Mon Sep 17 00:00:00 2001
b11b5f
From: David Tardon <dtardon@redhat.com>
b11b5f
Date: Tue, 29 Nov 2022 16:15:47 +0100
b11b5f
Subject: [PATCH] manager: move inc. of n_reloading into a function
b11b5f
b11b5f
[dtardon: This is inspired by commit d147e2b66b4d6b71db1bc59b62286b2eb9c3d29f ,
b11b5f
but it does just the minimal change needed for the next commit.]
b11b5f
b11b5f
Related: #2136869
b11b5f
---
b11b5f
 src/core/main.c    |  2 +-
b11b5f
 src/core/manager.c | 12 ++++++++----
b11b5f
 src/core/manager.h |  1 +
b11b5f
 3 files changed, 10 insertions(+), 5 deletions(-)
b11b5f
b11b5f
diff --git a/src/core/main.c b/src/core/main.c
b11b5f
index cfa6fec930..c3e2ce8956 100644
b11b5f
--- a/src/core/main.c
b11b5f
+++ b/src/core/main.c
b11b5f
@@ -1131,7 +1131,7 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching
b11b5f
                 return log_error_errno(r, "Failed to create serialization file: %m");
b11b5f
 
b11b5f
         /* Make sure nothing is really destructed when we shut down */
b11b5f
-        m->n_reloading++;
b11b5f
+        manager_reloading_start(m);
b11b5f
         bus_manager_send_reloading(m, true);
b11b5f
 
b11b5f
         fds = fdset_new();
b11b5f
diff --git a/src/core/manager.c b/src/core/manager.c
b11b5f
index f4611e6f8f..f923cbce37 100644
b11b5f
--- a/src/core/manager.c
b11b5f
+++ b/src/core/manager.c
b11b5f
@@ -1578,6 +1578,10 @@ static void manager_preset_all(Manager *m) {
b11b5f
                 log_info("Populated /etc with preset unit settings.");
b11b5f
 }
b11b5f
 
b11b5f
+void manager_reloading_start(Manager *m) {
b11b5f
+        m->n_reloading++;
b11b5f
+}
b11b5f
+
b11b5f
 int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
b11b5f
         int r;
b11b5f
 
b11b5f
@@ -1609,7 +1613,7 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
b11b5f
          * this is already known, so we increase the counter here
b11b5f
          * already */
b11b5f
         if (serialization)
b11b5f
-                m->n_reloading++;
b11b5f
+                manager_reloading_start(m);
b11b5f
 
b11b5f
         /* First, enumerate what we can from all config files */
b11b5f
         dual_timestamp_get(m->timestamps + MANAGER_TIMESTAMP_UNITS_LOAD_START);
b11b5f
@@ -3093,7 +3097,7 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) {
b11b5f
         assert(f);
b11b5f
         assert(fds);
b11b5f
 
b11b5f
-        m->n_reloading++;
b11b5f
+        manager_reloading_start(m);
b11b5f
 
b11b5f
         fprintf(f, "current-job-id=%"PRIu32"\n", m->current_job_id);
b11b5f
         fprintf(f, "n-installed-jobs=%u\n", m->n_installed_jobs);
b11b5f
@@ -3211,7 +3215,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
b11b5f
 
b11b5f
         log_debug("Deserializing state...");
b11b5f
 
b11b5f
-        m->n_reloading++;
b11b5f
+        manager_reloading_start(m);
b11b5f
 
b11b5f
         for (;;) {
b11b5f
                 _cleanup_free_ char *line = NULL;
b11b5f
@@ -3455,7 +3459,7 @@ int manager_reload(Manager *m) {
b11b5f
         if (r < 0)
b11b5f
                 return r;
b11b5f
 
b11b5f
-        m->n_reloading++;
b11b5f
+        manager_reloading_start(m);
b11b5f
         bus_manager_send_reloading(m, true);
b11b5f
 
b11b5f
         fds = fdset_new();
b11b5f
diff --git a/src/core/manager.h b/src/core/manager.h
b11b5f
index 3f2cfc5e2e..adbbb518cb 100644
b11b5f
--- a/src/core/manager.h
b11b5f
+++ b/src/core/manager.h
b11b5f
@@ -386,6 +386,7 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **m);
b11b5f
 Manager* manager_free(Manager *m);
b11b5f
 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
b11b5f
 
b11b5f
+void manager_reloading_start(Manager *m);
b11b5f
 int manager_startup(Manager *m, FILE *serialization, FDSet *fds);
b11b5f
 
b11b5f
 Job *manager_get_job(Manager *m, uint32_t id);