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       | 3 ---
 src/resolvers.c | 1 +
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/dns.c b/src/dns.c
index 83e0e7821..50f6e8ae0 100644
--- 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);
diff --git a/src/resolvers.c b/src/resolvers.c
index b6da43d88..65612ab92 100644
--- a/src/resolvers.c
+++ b/src/resolvers.c
@@ -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);
-- 
2.54.0

Reply via email to