From ef31b0902fa09fd9a03276b56a51d88d63e68c6f 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. --- 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 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<