summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/manager.c21
-rw-r--r--src/manager.h2
-rw-r--r--src/snapshot.c2
-rw-r--r--src/unit.c12
4 files changed, 28 insertions, 9 deletions
diff --git a/src/manager.c b/src/manager.c
index 9667e299f3..cdcd6935cd 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -544,6 +544,12 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
manager_build_unit_path_cache(m);
+ /* If we will deserialize make sure that during enumeration
+ * this is already known, so we increase the counter here
+ * already */
+ if (serialization)
+ m->n_deserializing ++;
+
/* First, enumerate what we can from all config files */
r = manager_enumerate(m);
@@ -556,6 +562,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
if ((q = manager_coldplug(m)) < 0)
r = q;
+ if (serialization) {
+ assert(m->n_deserializing > 0);
+ m->n_deserializing --;
+ }
+
/* Now that the initial devices are available, let's see if we
* can write the utmp file */
manager_write_utmp_reboot(m);
@@ -2334,7 +2345,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
log_debug("Deserializing state...");
- m->deserializing = true;
+ m->n_deserializing ++;
for (;;) {
Unit *u;
@@ -2366,7 +2377,8 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
r = 0;
finish:
- m->deserializing = false;
+ assert(m->n_deserializing > 0);
+ m->n_deserializing --;
return r;
}
@@ -2402,6 +2414,8 @@ int manager_reload(Manager *m) {
if ((q = lookup_paths_init(&m->lookup_paths, m->running_as)) < 0)
r = q;
+ m->n_deserializing ++;
+
/* First, enumerate what we can from all config files */
if ((q = manager_enumerate(m)) < 0)
r = q;
@@ -2417,6 +2431,9 @@ int manager_reload(Manager *m) {
if ((q = manager_coldplug(m)) < 0)
r = q;
+ assert(m->n_deserializing > 0);
+ m->n_deserializing ++;
+
finish:
if (f)
fclose(f);
diff --git a/src/manager.h b/src/manager.h
index 0eceab99ea..32fbacc461 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -192,7 +192,7 @@ struct Manager {
bool utmp_reboot_written:1;
- bool deserializing:1;
+ int n_deserializing;
bool show_status;
bool confirm_spawn;
diff --git a/src/snapshot.c b/src/snapshot.c
index 11e7c3e28d..e1583384cd 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -56,7 +56,7 @@ static int snapshot_load(Unit *u) {
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
- if (!s->by_snapshot_create && !s->meta.manager->deserializing)
+ if (!s->by_snapshot_create && s->meta.manager->n_deserializing <= 0)
return -ENOENT;
u->meta.load_state = UNIT_LOADED;
diff --git a/src/unit.c b/src/unit.c
index 3f42f0fa11..0c92756cb7 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1043,14 +1043,16 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
assert_not_reached("Job type unknown");
}
- /* If this state change happened without being
- * requested by a job, then let's retroactively start
- * or stop dependencies */
-
} else
unexpected = true;
- if (unexpected) {
+ /* If this state change happened without being requested by a
+ * job, then let's retroactively start or stop
+ * dependencies. We skip that step when deserializing, since
+ * we don't want to create any additional jobs just because
+ * something is already activated. */
+
+ if (unexpected && u->meta.manager->n_deserializing <= 0) {
if (UNIT_IS_INACTIVE_OR_DEACTIVATING(os) && UNIT_IS_ACTIVE_OR_ACTIVATING(ns))
retroactively_start_dependencies(u);
else if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))