Created
April 26, 2013 11:44
-
-
Save Habbie/5466799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: pdns/distributor.hh | |
=================================================================== | |
--- pdns/distributor.hh (revision 2708) | |
+++ pdns/distributor.hh (working copy) | |
@@ -171,15 +171,16 @@ | |
QuestionData QD=us->questions.front(); | |
+ us->questions.pop(); | |
+ pthread_mutex_unlock(&us->q_lock); | |
+ | |
Question *q=QD.Q; | |
- us->questions.pop(); | |
if(us->d_overloaded && qcount <= overloadQueueLength/10) { | |
us->d_overloaded=false; | |
} | |
- pthread_mutex_unlock(&us->q_lock); | |
Answer *a; | |
#ifndef SMTPREDIR | |
@@ -297,11 +298,12 @@ | |
pthread_create(&tid,0,&makeThread,static_cast<void *>(this)); | |
} | |
- pthread_mutex_lock(&q_lock); | |
QuestionData QD; | |
QD.Q=q; | |
QD.id=nextid++; | |
QD.callback=callback; | |
+ | |
+ pthread_mutex_lock(&q_lock); | |
questions.push(QD); | |
pthread_mutex_unlock(&q_lock); | |
Index: pdns/common_startup.cc | |
=================================================================== | |
--- pdns/common_startup.cc (revision 2708) | |
+++ pdns/common_startup.cc (working copy) | |
@@ -210,14 +210,21 @@ | |
delete AD.A; | |
} | |
-static DNSDistributor* g_distributor; | |
-static pthread_mutex_t d_distributorlock =PTHREAD_MUTEX_INITIALIZER; | |
-static bool g_mustlockdistributor; | |
//! The qthread receives questions over the internet via the Nameserver class, and hands them to the Distributor for further processing | |
void *qthread(void *number) | |
{ | |
DNSPacket *P; | |
+ DNSDistributor *g_distributor = new DNSDistributor(::arg().asNum("distributor-threads")); // the big dispatcher! | |
DNSPacket question; | |
DNSPacket cached; | |
@@ -298,12 +305,7 @@ | |
if(logDNSQueries) | |
L<<"packetcache MISS"<<endl; | |
- if(g_mustlockdistributor) { | |
- Lock l(&d_distributorlock); | |
- g_distributor->question(P, &sendout); // otherwise, give to the distributor | |
- } | |
- else | |
- g_distributor->question(P, &sendout); // otherwise, give to the distributor | |
+ g_distributor->question(P, &sendout); // otherwise, give to the distributor | |
} | |
return 0; | |
} | |
@@ -359,10 +361,7 @@ | |
TN->go(); // tcp nameserver launch | |
// fork(); (this worked :-)) | |
- g_distributor = new DNSDistributor(::arg().asNum("distributor-threads")); // the big dispatcher! | |
- if(::arg().asNum("receiver-threads") > 1) { | |
- g_mustlockdistributor=true; | |
- } | |
+ | |
unsigned int max_rthreads= ::arg().asNum("receiver-threads"); | |
for(int n=0; n < max_rthreads; ++n) | |
pthread_create(&qtid,0,qthread, reinterpret_cast<void *>(n)); // receives packets | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment