]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: sink: initialize the settings of the implicit log server
authorWilly Tarreau <w@1wt.eu>
Wed, 26 Aug 2026 13:26:35 +0000 (15:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Aug 2026 13:56:09 +0000 (15:56 +0200)
TCP logs currently work fairly badly due to connections closing
immediately after logs are sent (or at best a full buffer of logs).
This started to happen in 3.1 with commit 237849c911 ("MEDIUM: sink:
"max-reuse" support for sink servers") thow that commit is not faulty,
the issue stems to the complex server creation chain.

What happens is that max_reuse >= 0 means the max-reuse setting is
enable, and the sink server creation in sink_new_from_logger() creates
a server but doesn't initialize it. Other servers are not exactly
initialized, they're preset from defaults which are initialized. But
here we don't inherit defaults so we must call srv_settings_init(),
otherwise max_reuse remains zero and connections are closed after each
message.

This must be backported to 3.2.

src/sink.c

index cd12cb8472484ef4612ebd2435b081cb7529e5fc..2f98424f4cc31113aa15ca1b6d3398b48d6607a4 100644 (file)
@@ -1275,6 +1275,9 @@ struct sink *sink_new_from_logger(struct logger *logger)
        if (!srv)
                goto error;
 
+       /* there will be no defaults, we must initialize settings */
+       srv_settings_init(srv);
+
        /* init server */
        srv->id = strdup(logger->target.ring_name);
        srv->conf.file = strdup(logger->conf.file);