1
From da1afe50fe0cb828982925d454db2300a8f0b7af Mon Sep 17 00:00:00 2001
2
From: Tollef Fog Heen <tfheen@err.no>
3
Date: Tue, 16 Oct 2012 18:39:27 +0200
4
Subject: [PATCH 02/10] Avoid reloading services when shutting down
6
Doing so won't work and makes no sense. Thanks to Michael Stapelberg
7
for the patch. Closes: #624599.
9
src/core/manager.c | 26 ++++++++++++++++++++++++++
10
1 file changed, 26 insertions(+)
12
diff --git a/src/core/manager.c b/src/core/manager.c
13
index c7f8f20..20e5844 100644
14
--- a/src/core/manager.c
15
+++ b/src/core/manager.c
16
@@ -874,6 +874,8 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
17
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool override, DBusError *e, Job **_ret) {
24
assert(type < _JOB_TYPE_MAX);
25
@@ -885,6 +887,30 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove
29
+ if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START || type == JOB_RESTART || type == JOB_TRY_RESTART) {
30
+ /* If final.target is queued (happens on poweroff, reboot and
31
+ * halt), we will not accept new reload jobs. They would not be
32
+ * executed ever anyways (since the shutdown comes first), but
33
+ * they block the shutdown process: when systemd tries to stop
34
+ * a unit such as ifup@eth0.service, that unit might invoke a
35
+ * systemctl reload command, which blockingly waits (but only
36
+ * gets executed after all other queued units for the shutdown
37
+ * have been executed).
39
+ * See http://bugs.debian.org/624599 and
40
+ * http://bugs.debian.org/635777 */
41
+ HASHMAP_FOREACH(j, m->jobs, i) {
42
+ assert(j->installed);
44
+ if (strcmp(j->unit->id, "final.target") == 0) {
45
+ log_debug("final.target is queued, ignoring %s request for unit %s", job_type_to_string(type), unit->id);
46
+ dbus_set_error(e, BUS_ERROR_INVALID_JOB_MODE, "final.target is queued, ignoring %s request for unit %s", job_type_to_string(type), unit->id);
53
if (mode == JOB_ISOLATE && !unit->allow_isolate) {
54
dbus_set_error(e, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated.");