mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
journald-context: update ratelimit interval and burst on reload
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "daemon-util.h"
|
||||
#include "journald-audit.h"
|
||||
#include "journald-config.h"
|
||||
#include "journald-context.h"
|
||||
#include "journald-kmsg.h"
|
||||
#include "journald-manager.h"
|
||||
#include "journald-socket.h"
|
||||
@@ -373,6 +374,7 @@ int manager_dispatch_reload_signal(sd_event_source *s, const struct signalfd_sig
|
||||
(void) manager_reopen_dev_kmsg(m, old.read_kmsg);
|
||||
manager_reset_kernel_audit(m, old.set_audit);
|
||||
manager_reload_forward_socket(m, &old.forward_to_socket);
|
||||
manager_refresh_client_contexts_on_reload(m, old.ratelimit_interval, old.ratelimit_burst);
|
||||
|
||||
r = manager_reload_journals(m);
|
||||
if (r < 0)
|
||||
|
||||
@@ -190,6 +190,8 @@ static void client_context_reset(Manager *m, ClientContext *c) {
|
||||
|
||||
c->log_ratelimit_interval = m->config.ratelimit_interval;
|
||||
c->log_ratelimit_burst = m->config.ratelimit_burst;
|
||||
c->log_ratelimit_interval_from_unit = false;
|
||||
c->log_ratelimit_burst_from_unit = false;
|
||||
|
||||
c->log_filter_allowed_patterns = set_free(c->log_filter_allowed_patterns);
|
||||
c->log_filter_denied_patterns = set_free(c->log_filter_denied_patterns);
|
||||
@@ -496,7 +498,12 @@ static int client_context_read_log_ratelimit_interval(ClientContext *c) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return safe_atou64(value, &c->log_ratelimit_interval);
|
||||
r = safe_atou64(value, &c->log_ratelimit_interval);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
c->log_ratelimit_interval_from_unit = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int client_context_read_log_ratelimit_burst(ClientContext *c) {
|
||||
@@ -514,7 +521,12 @@ static int client_context_read_log_ratelimit_burst(ClientContext *c) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return safe_atou(value, &c->log_ratelimit_burst);
|
||||
r = safe_atou(value, &c->log_ratelimit_burst);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
c->log_ratelimit_burst_from_unit = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void client_context_really_refresh(
|
||||
@@ -599,6 +611,33 @@ refresh:
|
||||
client_context_really_refresh(m, c, ucred, label, label_size, unit_id, timestamp);
|
||||
}
|
||||
|
||||
static void client_context_refresh_on_reload(Manager *m, ClientContext *c) {
|
||||
assert(m);
|
||||
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
if (!c->log_ratelimit_interval_from_unit)
|
||||
c->log_ratelimit_interval = m->config.ratelimit_interval;
|
||||
|
||||
if (!c->log_ratelimit_burst_from_unit)
|
||||
c->log_ratelimit_burst = m->config.ratelimit_burst;
|
||||
}
|
||||
|
||||
void manager_refresh_client_contexts_on_reload(Manager *m, usec_t old_interval, unsigned old_burst) {
|
||||
assert(m);
|
||||
|
||||
if (m->config.ratelimit_interval == old_interval && m->config.ratelimit_burst == old_burst)
|
||||
return;
|
||||
|
||||
client_context_refresh_on_reload(m, m->my_context);
|
||||
client_context_refresh_on_reload(m, m->pid1_context);
|
||||
|
||||
ClientContext *c;
|
||||
HASHMAP_FOREACH(c, m->client_contexts)
|
||||
client_context_refresh_on_reload(m, c);
|
||||
}
|
||||
|
||||
static void client_context_try_shrink_to(Manager *m, size_t limit) {
|
||||
ClientContext *c;
|
||||
usec_t t;
|
||||
|
||||
@@ -50,6 +50,8 @@ typedef struct ClientContext {
|
||||
|
||||
usec_t log_ratelimit_interval;
|
||||
unsigned log_ratelimit_burst;
|
||||
bool log_ratelimit_interval_from_unit;
|
||||
bool log_ratelimit_burst_from_unit;
|
||||
|
||||
Set *log_filter_allowed_patterns;
|
||||
Set *log_filter_denied_patterns;
|
||||
@@ -81,6 +83,7 @@ void client_context_maybe_refresh(
|
||||
const char *unit_id,
|
||||
usec_t tstamp);
|
||||
|
||||
void manager_refresh_client_contexts_on_reload(Manager *m, usec_t old_interval, unsigned old_burst);
|
||||
void client_context_acquire_default(Manager *m);
|
||||
void client_context_flush_all(Manager *m);
|
||||
void client_context_flush_regular(Manager *m);
|
||||
|
||||
Reference in New Issue
Block a user