From ba98c6d7633284b5a4b48f77b59591fbb9f9af05 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 11 Dec 2014 13:57:35 +0100 Subject: [PATCH] fix startup race condition with carbon thread already trying to broadcast uninitialized data --- pdns/common_startup.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 3e81ba46c5..f4635c3e86 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -191,7 +191,10 @@ try { int totcount=0; BOOST_FOREACH(DNSDistributor* d, g_distributors) { + if(!d) + continue; int qcount, acount; + d->getQueueSizes(qcount, acount); // this does locking and other things, so don't get smart totcount+=qcount; } @@ -466,14 +469,14 @@ void mainthread() if(TN) TN->go(); // tcp nameserver launch - pthread_create(&qtid,0,carbonDumpThread, 0); // runs even w/o carbon, might change @ runtime - // fork(); (this worked :-)) unsigned int max_rthreads= ::arg().asNum("receiver-threads", 1); g_distributors.resize(max_rthreads); for(unsigned int n=0; n < max_rthreads; ++n) pthread_create(&qtid,0,qthread, reinterpret_cast(n)); // receives packets + pthread_create(&qtid,0,carbonDumpThread, 0); // runs even w/o carbon, might change @ runtime + for(;;) { sleep(1800); try { -- 2.47.2