b11b5f
From b9dd7ee5f4d0f6d51899d7e14ac7ef2fd2840b8f Mon Sep 17 00:00:00 2001
b11b5f
From: Lennart Poettering <lennart@poettering.net>
b11b5f
Date: Tue, 9 Oct 2018 17:37:57 +0200
b11b5f
Subject: [PATCH] core: bring manager_startup() and manager_reload() more
b11b5f
 inline
b11b5f
b11b5f
Both functions do partly the same, let's make sure they do it in the
b11b5f
same order, and that we don't miss some calls.
b11b5f
b11b5f
This makes a number of changes:
b11b5f
b11b5f
1. Moves exec_runtime_vacuum() two calls down in manager_startup(). This
b11b5f
   should not have any effect but makes manager_startup() more like
b11b5f
   manager_reload().
b11b5f
b11b5f
2. Calls manager_recheck_journal(), manager_recheck_dbus(),
b11b5f
   manager_enqueue_sync_bus_names() in manager_startup() too. This is a
b11b5f
   good idea since during reeexec we pass through manager_startup() and
b11b5f
   hence can't assume dbus and journald weren't up yet, hence let's
b11b5f
   check if they are ready to be connected to.
b11b5f
b11b5f
3. Include manager_enumerate_perpetual() in manager_reload(), too. This
b11b5f
   is not strictly necessary, since these units are included in the
b11b5f
   serialization anyway, but it's still a nice thing, in particular as
b11b5f
   theoretically the deserialization could fail.
b11b5f
b11b5f
(cherry picked from commit 3ad2afb6a204513c7834c64ab864e40169874390)
b11b5f
b11b5f
Resolves: #2059633
b11b5f
---
b11b5f
 src/core/manager.c | 14 +++++++++++---
b11b5f
 1 file changed, 11 insertions(+), 3 deletions(-)
b11b5f
b11b5f
diff --git a/src/core/manager.c b/src/core/manager.c
b11b5f
index e083596e58..4a9f9bfcf9 100644
b11b5f
--- a/src/core/manager.c
b11b5f
+++ b/src/core/manager.c
b11b5f
@@ -1665,12 +1665,12 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
b11b5f
         /* Release any dynamic users no longer referenced */
b11b5f
         dynamic_user_vacuum(m, true);
b11b5f
 
b11b5f
-        exec_runtime_vacuum(m);
b11b5f
-
b11b5f
         /* Release any references to UIDs/GIDs no longer referenced, and destroy any IPC owned by them */
b11b5f
         manager_vacuum_uid_refs(m);
b11b5f
         manager_vacuum_gid_refs(m);
b11b5f
 
b11b5f
+        exec_runtime_vacuum(m);
b11b5f
+
b11b5f
         if (serialization) {
b11b5f
                 assert(m->n_reloading > 0);
b11b5f
                 m->n_reloading--;
b11b5f
@@ -1681,6 +1681,13 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
b11b5f
                 m->send_reloading_done = true;
b11b5f
         }
b11b5f
 
b11b5f
+        /* It might be safe to log to the journal now and connect to dbus */
b11b5f
+        manager_recheck_journal(m);
b11b5f
+        manager_recheck_dbus(m);
b11b5f
+
b11b5f
+        /* Sync current state of bus names with our set of listening units */
b11b5f
+        (void) manager_enqueue_sync_bus_names(m);
b11b5f
+
b11b5f
         /* Let's finally catch up with any changes that took place while we were reloading/reexecing */
b11b5f
         manager_catchup(m);
b11b5f
 
b11b5f
@@ -3505,7 +3512,8 @@ int manager_reload(Manager *m) {
b11b5f
         lookup_paths_reduce(&m->lookup_paths);
b11b5f
         manager_build_unit_path_cache(m);
b11b5f
 
b11b5f
-        /* First, enumerate what we can from all config files */
b11b5f
+        /* First, enumerate what we can from kernel and suchlike */
b11b5f
+        manager_enumerate_perpetual(m);
b11b5f
         manager_enumerate(m);
b11b5f
 
b11b5f
         /* Second, deserialize our stored data */