From ceaa1ddb06a584e0c93d194e7b3653d73eb008ca Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Fri, 23 Jun 2023 15:56:58 +0200 Subject: [PATCH] MINOR: log/sink: detect when log maxlen exceeds sink size To prevent logs from being silently (and unexpectly droppped) at runtime, we check that the maxlen parameter from the log directives are strictly inferior to the targeted ring size. |global | tune.bufsize 16384 | log tcp@127.0.0.1:514 len 32768 | log myring@127.0.0.1:514 len 32768 |ring myring | # no explicit size On such configs, a diag warning will be reported. This commit depends on: - "MINOR: sink: simplify post_sink_resolve function" - "MINOR: ring: add a function to compute max ring payload" --- src/sink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sink.c b/src/sink.c index 0a5670bf2..33824633e 100644 --- a/src/sink.c +++ b/src/sink.c @@ -1299,6 +1299,12 @@ int sink_postresolve_logsrvs(struct list *logsrvs, const char *section, const ch logsrv->conf.file, logsrv->conf.line, logsrv->ring_name); err_code |= ERR_ALERT | ERR_FATAL; } + if (sink && logsrv->maxlen > ring_max_payload(sink->ctx.ring)) { + _e_sink_postresolve_logsrvs(ha_diag_warning, "log server", "uses a max length which exceeds ring capacity ('%s' supports %lu bytes at most).", + section, section_name, + logsrv->conf.file, logsrv->conf.line, + logsrv->ring_name, (unsigned long)ring_max_payload(sink->ctx.ring)); + } logsrv->sink = sink; }