]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: resolvers: don't dump a nameserver twice in "show resolvers"
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 29 Sep 2026 07:28:45 +0000 (09:28 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 10 Nov 2026 14:47:52 +0000 (15:47 +0100)
When the output buffer is full, "show resolvers" yields and resumes from
the nameserver saved in its context. But this one is only updated after a
nameserver was successfully dumped, so the dump resumes from the last
nameserver already dumped, which appears twice in the output, instead of
the one which could not be dumped.

This can be reproduced with 40 nameservers in a section and
"tune.bufsize 4096": "show resolvers" lists 43 nameservers, ns13, ns25
and ns37 appearing twice.

Let's save the nameserver being dumped before trying to dump it instead.

This patch should be backported to all stable branches.

src/resolvers.c

index addc98836a1365769bc4f1654f04ac92a5770393..a3091b95d3be5ba8d818f5286a404a518ecc2b25 100644 (file)
@@ -3208,6 +3208,8 @@ static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx)
                        }
 
                        list_for_each_entry_from(ns, &resolvers->nameservers, list) {
+                               /* restart from this one if the buffer is full */
+                               ctx->ns = ns;
                                chunk_reset(&trash);
                                chunk_appendf(&trash, " nameserver %s:\n", ns->id);
                                chunk_appendf(&trash, "  sent:         %lld\n", ns->counters->sent);
@@ -3228,7 +3230,6 @@ static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx)
                                chunk_appendf(&trash, "  outdated:     %lld\n", ns->counters->app.resolver.outdated);
                                if (applet_putchk(appctx, &trash) == -1)
                                        goto full;
-                               ctx->ns = ns;
                        }
 
                        ctx->ns = NULL;