summaryrefslogtreecommitdiffstats
path: root/src/core/manager-serialize.c
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2023-10-20 01:34:29 +0200
committerLuca Boccassi <bluca@debian.org>2024-04-17 19:19:27 +0200
commit8c15bf36e117054cf54b4f0cca59615b7531a545 (patch)
tree7c59b78400a159d5e098f038f1e01bf3aaf43986 /src/core/manager-serialize.c
parentMerge pull request #32143 from yuwata/magic (diff)
downloadsystemd-8c15bf36e117054cf54b4f0cca59615b7531a545.tar.xz
systemd-8c15bf36e117054cf54b4f0cca59615b7531a545.zip
manager: serialize current objective
So that we can tell what happened before the exec. It is overwritten shortly after deserialization. Use it to bump the soft reboots counter.
Diffstat (limited to 'src/core/manager-serialize.c')
-rw-r--r--src/core/manager-serialize.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/manager-serialize.c b/src/core/manager-serialize.c
index 884332b324..6008e5655e 100644
--- a/src/core/manager-serialize.c
+++ b/src/core/manager-serialize.c
@@ -158,6 +158,9 @@ int manager_serialize(
(void) serialize_ratelimit(f, "dump-ratelimit", &m->dump_ratelimit);
(void) serialize_ratelimit(f, "reload-reexec-ratelimit", &m->reload_reexec_ratelimit);
+ if (m->objective >= 0 && m->objective < _MANAGER_OBJECTIVE_MAX)
+ (void) serialize_item_format(f, "previous-objective", "%u", (unsigned) m->objective);
+
bus_track_serialize(m->subscribed, f, "subscribed");
r = dynamic_user_serialize(m, f, fds);
@@ -529,6 +532,14 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
log_notice("Failed to parse soft reboots counter '%s', ignoring.", val);
else
m->soft_reboots_count = n;
+ } else if ((val = startswith(l, "previous-objective="))) {
+ unsigned n;
+
+ if (safe_atou(val, &n) < 0 || n >= _MANAGER_OBJECTIVE_MAX)
+ log_notice("Failed to parse objective '%s', ignoring.", val);
+ else
+ m->previous_objective = n;
+
} else {
ManagerTimestamp q;