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.
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);
}