ryantimwilson / rpms / systemd

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