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: auth-4.3.0-alpha1~40^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8559%2Fhead;p=thirdparty%2Fpdns.git Avoid startup race by setting the state of a tread before starting it. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 76a99b86f9..ce634c3d0e 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -4290,13 +4290,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<