log_debug("Deserializing state...");
+ m->deserializing = true;
+
for (;;) {
Unit *u;
char name[UNIT_NAME_MAX+2];
if (feof(f))
break;
- return -errno;
+ r = -errno;
+ goto finish;
}
char_array_0(name);
if ((r = manager_load_unit(m, strstrip(name), NULL, NULL, &u)) < 0)
- return r;
+ goto finish;
if ((r = unit_deserialize(u, f, fds)) < 0)
- return r;
+ goto finish;
}
- if (ferror(f))
- return -EIO;
+ if (ferror(f)) {
+ r = -EIO;
+ goto finish;
+ }
- return 0;
+ r = 0;
+
+finish:
+ m->deserializing = false;
+
+ return r;
}
int manager_reload(Manager *m) {
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
- if (!s->by_snapshot_create)
+ if (!s->by_snapshot_create && !s->meta.manager->deserializing)
return -ENOENT;
u->meta.load_state = UNIT_LOADED;