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