core: serialize and deserialize unit start ratelimits
The logic is taken from dump ratelimit: if the config changes, we discard the counters. This allows the user apply new limits and "start from scratch" in that case. This actually makes StartLimitIntervalSec=infinity (or with a large interval) work as expected, because the counter is maintained even if daemon-reload operations are interleaved.
This commit is contained in:
committed by
Luca Boccassi
parent
07a6647abb
commit
6ef512c0bb
@@ -140,6 +140,8 @@ int unit_serialize_state(Unit *u, FILE *f, FDSet *fds, bool switching_root) {
|
||||
(void) serialize_dual_timestamp(f, "condition-timestamp", &u->condition_timestamp);
|
||||
(void) serialize_dual_timestamp(f, "assert-timestamp", &u->assert_timestamp);
|
||||
|
||||
(void) serialize_ratelimit(f, "start-ratelimit", &u->start_ratelimit);
|
||||
|
||||
if (dual_timestamp_is_set(&u->condition_timestamp))
|
||||
(void) serialize_bool(f, "condition-result", u->condition_result);
|
||||
|
||||
@@ -343,6 +345,10 @@ int unit_deserialize_state(Unit *u, FILE *f, FDSet *fds) {
|
||||
(void) deserialize_dual_timestamp(v, &u->assert_timestamp);
|
||||
continue;
|
||||
|
||||
} else if (streq(l, "start-ratelimit")) {
|
||||
deserialize_ratelimit(&u->start_ratelimit, l, v);
|
||||
continue;
|
||||
|
||||
} else if (MATCH_DESERIALIZE("condition-result", l, v, parse_boolean, u->condition_result))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user