Uphold/StopWhenUnneeded/BindsTo: add retry timer on rate limit

The Upholds= promise is that as long as unit A is up and Upholds=B,
B will be activated if failed or inactive. But there is a hard-coded,
non-configurable rate limit for this, so add a timed retry after the
ratelimit has expired.

Apply to BindsTo= and StopWhenUnneeded= as well.
This commit is contained in:
Luca Boccassi
2023-04-12 21:49:48 +01:00
parent 5015b5014b
commit 7223d500ac
5 changed files with 73 additions and 6 deletions
+9
View File
@@ -38,3 +38,12 @@ unsigned ratelimit_num_dropped(RateLimit *r) {
return r->num > r->burst ? r->num - r->burst : 0;
}
usec_t ratelimit_end(const RateLimit *rl) {
assert(rl);
if (rl->begin == 0)
return 0;
return usec_add(rl->begin, rl->interval);
}
+2
View File
@@ -23,3 +23,5 @@ static inline bool ratelimit_configured(RateLimit *rl) {
bool ratelimit_below(RateLimit *r);
unsigned ratelimit_num_dropped(RateLimit *r);
usec_t ratelimit_end(const RateLimit *rl);