[systemd-commits] src/manager.c src/unit.c
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Aug 11 11:19:34 PDT 2010
src/manager.c | 44 +++++++++++++++++++++++++++++++++++++++-----
src/unit.c | 1 +
2 files changed, 40 insertions(+), 5 deletions(-)
New commits:
commit 10f8e83cbb10c73b980c9b3b895ac044e600ba0c
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Aug 11 20:19:27 2010 +0200
manager: serialize/deserialize startup time, too
diff --git a/src/manager.c b/src/manager.c
index a5b0ce0..18b0140 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -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;
@@ -2383,15 +2387,47 @@ 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];
/* 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 --;
diff --git a/src/unit.c b/src/unit.c
index 33e9cef..59fc93a 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1983,6 +1983,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
return -errno;
}
+ char_array_0(line);
l = strstrip(line);
/* End marker */
More information about the systemd-commits
mailing list