]> err.no Git - systemd/commitdiff
snapshot: fix deserialization
authorLennart Poettering <lennart@poettering.net>
Sat, 10 Jul 2010 02:51:03 +0000 (04:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 10 Jul 2010 02:51:03 +0000 (04:51 +0200)
src/manager.c
src/manager.h
src/snapshot.c

index a643263213a2988c563a03f5f6d7b7f9d76075d5..bd4f4659afb77c1fc0ded97f07f645cd489b3435 100644 (file)
@@ -2279,6 +2279,8 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
 
         log_debug("Deserializing state...");
 
+        m->deserializing = true;
+
         for (;;) {
                 Unit *u;
                 char name[UNIT_NAME_MAX+2];
@@ -2288,22 +2290,30 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
                         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) {
index e5cf3a1c520d5831af7a72f9cea817a47fff7ab0..b44ffe27ce08215897d2c8ff70e152edd5f5b2fa 100644 (file)
@@ -193,6 +193,8 @@ struct Manager {
 
         bool utmp_reboot_written:1;
 
+        bool deserializing:1;
+
         bool show_status;
         bool confirm_spawn;
 };
index fe8a43dd3a396d7a5bb1b8dfa14aab178438801b..11e7c3e28d9a7b0a9541de5ed31715520af8d667 100644 (file)
@@ -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)
+        if (!s->by_snapshot_create && !s->meta.manager->deserializing)
                 return -ENOENT;
 
         u->meta.load_state = UNIT_LOADED;