From 3835439617e98a1e451f51382add2bf6f54533c7 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 20 Nov 2019 12:26:14 +0100 Subject: [PATCH] Avoid startup race by setting the state of a tread before starting it. (cherry picked from commit ef31b0902fa09fd9a03276b56a51d88d63e68c6f) --- pdns/pdns_recursor.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index d9032cf84c..d5f05dee87 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -4065,13 +4065,24 @@ static int serviceMain(int argc, char*argv[]) } else { + + if (g_weDistributeQueries) { + for(unsigned int n=0; n < g_numDistributorThreads; ++n) { + auto& infos = s_threadInfos.at(currentThreadId + n); + infos.isListener = true; + } + } + for(unsigned int n=0; n < g_numWorkerThreads; ++n) { + auto& infos = s_threadInfos.at(currentThreadId + (g_weDistributeQueries ? g_numDistributorThreads : 0) + n); + infos.isListener = !g_weDistributeQueries; + infos.isWorker = true; + } + if (g_weDistributeQueries) { g_log<