mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
core: use uniform style for RateLimit initialization
RateLimit is designed so that we can always initialize only the first two fields explicitly. All other call sites use a single line for this.
This commit is contained in:
committed by
Luca Boccassi
parent
b2bd488e76
commit
fed25720ef
@@ -12,6 +12,8 @@ typedef struct RateLimit {
|
||||
usec_t begin;
|
||||
} RateLimit;
|
||||
|
||||
#define RATELIMIT_OFF (const RateLimit) { .interval = USEC_INFINITY, .burst = UINT_MAX }
|
||||
|
||||
static inline void ratelimit_reset(RateLimit *rl) {
|
||||
rl->num = rl->begin = 0;
|
||||
}
|
||||
|
||||
@@ -927,10 +927,7 @@ int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags,
|
||||
.first_boot = -1,
|
||||
.test_run_flags = test_run_flags,
|
||||
|
||||
.dump_ratelimit = {
|
||||
.interval = 10 * USEC_PER_MINUTE,
|
||||
.burst = 10,
|
||||
},
|
||||
.dump_ratelimit = (const RateLimit) { .interval = 10 * USEC_PER_MINUTE, .burst = 10 },
|
||||
|
||||
.executor_fd = -EBADF,
|
||||
};
|
||||
|
||||
@@ -279,8 +279,7 @@ static void path_init(Unit *u) {
|
||||
|
||||
p->directory_mode = 0755;
|
||||
|
||||
p->trigger_limit.interval = USEC_INFINITY;
|
||||
p->trigger_limit.burst = UINT_MAX;
|
||||
p->trigger_limit = RATELIMIT_OFF;
|
||||
}
|
||||
|
||||
void path_free_specs(Path *p) {
|
||||
|
||||
@@ -100,8 +100,7 @@ static void socket_init(Unit *u) {
|
||||
s->control_pid = PIDREF_NULL;
|
||||
s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
|
||||
|
||||
s->trigger_limit.interval = USEC_INFINITY;
|
||||
s->trigger_limit.burst = UINT_MAX;
|
||||
s->trigger_limit = RATELIMIT_OFF;
|
||||
|
||||
s->poll_limit_interval = USEC_INFINITY;
|
||||
s->poll_limit_burst = UINT_MAX;
|
||||
|
||||
@@ -132,15 +132,12 @@ Unit* unit_new(Manager *m, size_t size) {
|
||||
|
||||
u->last_section_private = -1;
|
||||
|
||||
u->start_ratelimit = (RateLimit) {
|
||||
u->start_ratelimit = (const RateLimit) {
|
||||
m->defaults.start_limit_interval,
|
||||
m->defaults.start_limit_burst
|
||||
m->defaults.start_limit_burst,
|
||||
};
|
||||
|
||||
u->auto_start_stop_ratelimit = (const RateLimit) {
|
||||
10 * USEC_PER_SEC,
|
||||
16
|
||||
};
|
||||
u->auto_start_stop_ratelimit = (const RateLimit) { .interval = 10 * USEC_PER_SEC, .burst = 16 };
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user