]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: make sure we send our calling service manager RELOADING=1 when reloading
authorLennart Poettering <lennart@poettering.net>
Mon, 2 Jan 2023 14:01:56 +0000 (15:01 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 10 Jan 2023 17:28:38 +0000 (18:28 +0100)
And send READY=1 again when we are done with it.

We do this not only for "daemon-reload" but also for "daemon-reexec" and
"switch-root", since from the perspective of an encapsulating service
manager these three operations are not that different.

src/core/main.c
src/core/manager.c
src/core/manager.h
units/user@.service.in

index c833050db0af9ac647282bfe08563d842dd7071e..94055f08de90ec01b18610f77b51fe25ec777bd3 100644 (file)
@@ -1961,6 +1961,8 @@ static int invoke_main_loop(
                         LogTarget saved_log_target;
                         int saved_log_level;
 
+                        manager_send_reloading(m);
+
                         log_info("Reloading.");
 
                         /* First, save any overridden log level/target, then parse the configuration file,
@@ -1991,6 +1993,10 @@ static int invoke_main_loop(
                 }
 
                 case MANAGER_REEXECUTE:
+
+                        manager_send_reloading(m); /* From the perspective of the manager calling us this is
+                                                    * pretty much the same as a reload */
+
                         r = prepare_reexecute(m, &arg_serialization, ret_fds, false);
                         if (r < 0) {
                                 *ret_error_message = "Failed to prepare for reexecution";
@@ -2005,6 +2011,10 @@ static int invoke_main_loop(
                         return objective;
 
                 case MANAGER_SWITCH_ROOT:
+
+                        manager_send_reloading(m); /* From the perspective of the manager calling us this is
+                                                    * pretty much the same as a reload */
+
                         manager_set_switching_root(m, true);
 
                         if (!m->switch_root_init) {
index 0aed7de15c740385109e1267fa039fb46eb76c97..f8576cca1aeb5722f8cc6079ff2c1c38d232d3f7 100644 (file)
@@ -3648,6 +3648,18 @@ void manager_check_finished(Manager *m) {
         manager_invalidate_startup_units(m);
 }
 
+void manager_send_reloading(Manager *m) {
+        assert(m);
+
+        /* Let whoever invoked us know that we are now reloading */
+        (void) sd_notifyf(/* unset= */ false,
+                          "RELOADING=1\n"
+                          "MONOTONIC_USEC=" USEC_FMT "\n", now(CLOCK_MONOTONIC));
+
+        /* And ensure that we'll send READY=1 again as soon as we are ready again */
+        m->ready_sent = false;
+}
+
 static bool generator_path_any(const char* const* paths) {
         bool found = false;
 
index 4d4b56c3cc0d4999283068146562eae2c39012da..c13de8fe78ff78507bcb508b89a054a557565c9c 100644 (file)
@@ -538,6 +538,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u);
 bool manager_unit_inactive_or_pending(Manager *m, const char *name);
 
 void manager_check_finished(Manager *m);
+void manager_send_reloading(Manager *m);
 
 void disable_printk_ratelimit(void);
 void manager_recheck_dbus(Manager *m);
index 1660de03264bd10177c166a372c556228f65c839..15587649094b672f75113729d5d881a2d334c509 100644 (file)
@@ -17,7 +17,7 @@ IgnoreOnIsolate=yes
 [Service]
 User=%i
 PAMName=systemd-user
-Type=notify
+Type=notify-reload
 ExecStart={{ROOTLIBEXECDIR}}/systemd --user
 Slice=user-%i.slice
 KillMode=mixed