]> err.no Git - systemd/commitdiff
manager: serialize/deserialize startup time, too
authorLennart Poettering <lennart@poettering.net>
Wed, 11 Aug 2010 18:19:27 +0000 (20:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 Aug 2010 18:19:27 +0000 (20:19 +0200)
src/manager.c
src/unit.c

index a5b0ce002d1a0f292df4930504a7879345ffd1de..18b014004f31ecb9376e8ae886c48844d5bb9cd0 100644 (file)
@@ -2351,6 +2351,10 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds) {
         assert(f);
         assert(fds);
 
+        fprintf(f, "startup-timestamp=%llu %llu\n\n",
+                (unsigned long long) m->startup_timestamp.realtime,
+                (unsigned long long) m->startup_timestamp.monotonic);
+
         HASHMAP_FOREACH_KEY(u, t, m->units, i) {
                 if (u->meta.id != t)
                         continue;
@@ -2382,6 +2386,37 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
 
         m->n_deserializing ++;
 
+        for (;;) {
+                char line[1024], *l;
+
+                if (!fgets(line, sizeof(line), f)) {
+                        if (feof(f))
+                                r = 0;
+                        else
+                                r = -errno;
+
+                        goto finish;
+                }
+
+                char_array_0(line);
+                l = strstrip(line);
+
+                if (l[0] == 0)
+                        break;
+
+                if (startswith(l, "startup-timestamp=")) {
+                        unsigned long long a, b;
+
+                        if (sscanf(l+18, "%lli %llu", &a, &b) != 2)
+                                log_debug("Failed to parse startup timestamp value %s", l+18);
+                        else {
+                                m->startup_timestamp.realtime = a;
+                                m->startup_timestamp.monotonic = b;
+                        }
+                } else
+                        log_debug("Unknown serialization item '%s'", l);
+        }
+
         for (;;) {
                 Unit *u;
                 char name[UNIT_NAME_MAX+2];
@@ -2389,9 +2424,10 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
                 /* Start marker */
                 if (!fgets(name, sizeof(name), f)) {
                         if (feof(f))
-                                break;
+                                r = 0;
+                        else
+                                r = -errno;
 
-                        r = -errno;
                         goto finish;
                 }
 
@@ -2404,14 +2440,12 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
                         goto finish;
         }
 
+finish:
         if (ferror(f)) {
                 r = -EIO;
                 goto finish;
         }
 
-        r = 0;
-
-finish:
         assert(m->n_deserializing > 0);
         m->n_deserializing --;
 
index 33e9cef86508cc9a6f902de10e1426aac69847a0..59fc93a9ba3d74487f8c3a144bc49d3b6b25e071 100644 (file)
@@ -1983,6 +1983,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
                         return -errno;
                 }
 
+                char_array_0(line);
                 l = strstrip(line);
 
                 /* End marker */