naccyde / rpms / systemd

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