Changeset 1316
- Timestamp:
- 11/27/08 23:26:42 (21 months ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/common_startup.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/common_startup.cc
r1285 r1316 65 65 ::arg().set("default-soa-name","name to insert in the SOA record if none set in the backend")="a.misconfigured.powerdns.server"; 66 66 ::arg().set("distributor-threads","Default number of Distributor (backend) threads to start")="3"; 67 ::arg().set("receiver-threads","Default number of Distributor (backend) threads to start")="1"; 67 68 ::arg().set("queue-limit","Maximum number of milliseconds to queue a query")="1500"; 68 69 ::arg().set("recursor","If recursion is desired, IP address of a recursing nameserver")="no"; … … 203 204 } 204 205 206 static DNSDistributor* g_distributor; 207 static pthread_mutex_t d_distributorlock =PTHREAD_MUTEX_INITIALIZER; 208 static bool g_mustlockdistributor; 205 209 206 210 //! The qthread receives questions over the internet via the Nameserver class, and hands them to the Distributor for futher processing 207 void *qthread(void *p) 208 { 209 DNSDistributor *D=static_cast<DNSDistributor *>(p); 210 211 void *qthread(void *number) 212 { 211 213 DNSPacket *P; 212 214 … … 226 228 227 229 for(;;) { 228 if(!((numreceived++)%50)) { // maintenance tasks 229 S.set("latency",(int)avg_latency); 230 int qcount, acount; 231 D->getQueueSizes(qcount, acount); 232 S.set("qsize-q",qcount); 230 if(number==0) { 231 if(!((numreceived++)%50)) { // maintenance tasks 232 S.set("latency",(int)avg_latency); 233 int qcount, acount; 234 g_distributor->getQueueSizes(qcount, acount); 235 S.set("qsize-q",qcount); 236 } 233 237 } 234 238 235 239 if(!(P=N->receive(&question))) { // receive a packet inline 236 240 continue; // packet was broken, try again … … 265 269 continue; 266 270 } 267 268 D->question(P, &sendout); // otherwise, give to the distributor 271 if(g_mustlockdistributor) { 272 Lock l(&d_distributorlock); 273 g_distributor->question(P, &sendout); // otherwise, give to the distributor 274 } 275 else 276 g_distributor->question(P, &sendout); // otherwise, give to the distributor 269 277 } 270 278 return 0; … … 319 327 320 328 // fork(); (this worked :-)) 321 DNSDistributor *D= new DNSDistributor(::arg().asNum("distributor-threads")); // the big dispatcher! 322 pthread_create(&qtid,0,qthread,static_cast<void *>(D)); // receives packets 329 g_distributor = new DNSDistributor(::arg().asNum("distributor-threads")); // the big dispatcher! 330 if(::arg().asNum("receiver-threads") > 1) { 331 g_mustlockdistributor=true; 332 } 333 for(int n=0; n < ::arg().asNum("receiver-threads"); ++n) 334 pthread_create(&qtid,0,qthread, reinterpret_cast<void *>(n)); // receives packets 323 335 324 336 void *p;