summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/main.c5
-rw-r--r--src/core/manager-serialize.c11
-rw-r--r--src/core/manager.c6
-rw-r--r--src/core/manager.h2
4 files changed, 19 insertions, 5 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 8c8cf8b4a7..7ef66c8673 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -3192,11 +3192,6 @@ int main(int argc, char *argv[]) {
goto finish;
}
- /* If we got a SoftRebootStart timestamp during deserialization, then we are in a new soft-reboot
- * iteration, so bump the counter now before starting units, so that they can reliably read it. */
- if (dual_timestamp_is_set(&m->timestamps[MANAGER_TIMESTAMP_SOFTREBOOT_START]))
- m->soft_reboots_count++;
-
/* This will close all file descriptors that were opened, but not claimed by any unit. */
fds = fdset_free(fds);
arg_serialization = safe_fclose(arg_serialization);
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;
diff --git a/src/core/manager.c b/src/core/manager.c
index 52f5e72e11..1fb0f7dd21 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -882,6 +882,7 @@ int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags,
*m = (Manager) {
.runtime_scope = runtime_scope,
.objective = _MANAGER_OBJECTIVE_INVALID,
+ .previous_objective = _MANAGER_OBJECTIVE_INVALID,
.status_unit_format = STATUS_UNIT_FORMAT_DEFAULT,
@@ -1973,6 +1974,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *roo
return log_error_errno(r, "Deserialization failed: %m");
}
+ /* If we are in a new soft-reboot iteration bump the counter now before starting units, so
+ * that they can reliably read it. We get the previous objective from serialized state. */
+ if (m->previous_objective == MANAGER_SOFT_REBOOT)
+ m->soft_reboots_count++;
+
/* Any fds left? Find some unit which wants them. This is useful to allow container managers to pass
* some file descriptors to us pre-initialized. This enables socket-based activation of entire
* containers. */
diff --git a/src/core/manager.h b/src/core/manager.h
index 9541a5e0b4..afc49a2f19 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -379,6 +379,8 @@ struct Manager {
bool etc_localtime_accessible;
ManagerObjective objective;
+ /* Objective as it was before serialization, mostly to detect soft-reboots */
+ ManagerObjective previous_objective;
/* Flags */
bool dispatching_load_queue;