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);
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);
log_debug("Deserializing state...");
- m->deserializing = true;
+ m->n_deserializing ++;
for (;;) {
Unit *u;
r = 0;
finish:
- m->deserializing = false;
+ assert(m->n_deserializing > 0);
+ m->n_deserializing --;
return r;
}
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;
if ((q = manager_coldplug(m)) < 0)
r = q;
+ assert(m->n_deserializing > 0);
+ m->n_deserializing ++;
+
finish:
if (f)
fclose(f);
/* 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;
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))