]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: dns: schedule idle task after setting its thread
authorManu Nicolas <e.nicolas@criteo.com>
Tue, 18 Aug 2026 17:24:47 +0000 (17:24 +0000)
committerWilly Tarreau <w@1wt.eu>
Wed, 19 Aug 2026 09:19:51 +0000 (11:19 +0200)
Commit b8a311f49 ("MEDIUM: dns: Stick the TCP nameserver tasks to the
resolvers' thread") assigns each stream nameserver task to the resolver
thread during configuration finalization. However, dns_stream_init()
has already queued the idle task by then.

task_set_thread() removes the task from its old wait queue and queues
it again after changing its owner. The current thread still belongs to
the old owner, which violates wait-queue ownership. Strict builds hit
the task->tid assertion while finalizing a configuration containing a
TCP nameserver.

Leave the idle task unqueued during stream initialization. Once
finalization has set all three stream task affinities, wake the idle
task so it schedules its expiration on the resolver thread.

No backport is needed. The offending commit is only present in the
development branch.

src/dns.c
src/resolvers.c

index 83e0e7821f9f234349cf21fbfa5ca1001fbbdd7f..50f6e8ae0669697f8a99a94cba4efe0533f0e3c6 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -1399,9 +1399,6 @@ int dns_stream_init(struct dns_nameserver *ns, struct server *srv)
        dss->task_idle->context = dss;
        dss->task_idle->expire = tick_add(now_ms, 5000);
 
-       /* let start the task to free idle conns immediately */
-       task_queue(dss->task_idle);
-
        LIST_INIT(&dss->free_sess);
        LIST_INIT(&dss->idle_sess);
        LIST_INIT(&dss->wait_sess);
index b6da43d887130dcd1aadbc278a3d2e18325d7d54..65612ab9230248f112a5ad1042a377ddd2e27e48 100644 (file)
@@ -2827,6 +2827,7 @@ static int resolvers_finalize_config(void)
                                task_set_thread(ns->stream->task_req, t->tid);
                                task_set_thread(ns->stream->task_rsp, t->tid);
                                task_set_thread(ns->stream->task_idle, t->tid);
+                               task_wakeup(ns->stream->task_idle, TASK_WOKEN_INIT);
                        }
                }
                task_wakeup(t, TASK_WOKEN_INIT);