From b8a311f49f177802e00f2b91b05294926641a772 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Thu, 30 Jul 2026 00:26:58 +0200 Subject: [PATCH] MEDIUM: dns: Stick the TCP nameserver tasks to the resolvers' thread The tasks handling the TCP nameservers (task_req, task_rsp, task_idle) are created with no thread affinity, but with thread groups having their own file descriptors table, it has to run on the same thread as the one who created the socket, or maybe the other thread will not be able to use the socket. In practice, it was not a problem, because the scheduler will wake the task on the running thread. But that may change in the future, so make sure we always run on the current thread from start to finish. --- src/resolvers.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/resolvers.c b/src/resolvers.c index c166ccaa6..6a2467564 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -2805,6 +2805,21 @@ static int resolvers_finalize_config(void) t->process = process_resolvers; t->context = resolvers; resolvers->t = t; + + /* + * Make sure we run those tasks on the same thread that + * takes care of those resolvers, as it will create the + * socket, and with separate file descriptors tables for + * each thread group, we want to make sure we will + * run on a thread that can actually use them. + */ + list_for_each_entry(ns, &resolvers->nameservers, list) { + if (ns->stream) { + 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(t, TASK_WOKEN_INIT); } -- 2.47.3