From: Otto Moerbeek Date: Wed, 20 Nov 2019 11:26:14 +0000 (+0100) Subject: Avoid startup race by setting the state of a tread before starting it. X-Git-Tag: rec-4.2.2~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8802%2Fhead;p=thirdparty%2Fpdns.git Avoid startup race by setting the state of a tread before starting it. (cherry picked from commit ef31b0902fa09fd9a03276b56a51d88d63e68c6f) --- 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<