Changeset 701
- Timestamp:
- 04/14/06 17:43:31 (4 years ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/dnsreplay-mindex.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dnsreplay-mindex.cc
r608 r701 114 114 } 115 115 116 uint16_t getID()116 uint16_t peakID() 117 117 { 118 118 uint16_t ret; 119 119 if(!d_available.empty()) { 120 120 ret=d_available.front(); 121 d_available.pop_front();122 121 return ret; 123 122 } 124 123 else 125 124 throw runtime_error("out of ids!"); // XXX FIXME 125 } 126 127 uint16_t getID() 128 { 129 uint16_t ret=peakID(); 130 d_available.pop_front(); 131 return ret; 126 132 } 127 133 … … 326 332 qids_by_id_index_t::const_iterator found=idindex.find(ntohs(mdp.d_header.id)); 327 333 if(found == idindex.end()) { 328 cout<<"Received an answer ("<<mdp.d_qname<<") from reference nameserver with id "<<mdp.d_header.id<<" which we can't match to a question!"<<endl;334 // cout<<"Received an answer ("<<mdp.d_qname<<") from reference nameserver with id "<<mdp.d_header.id<<" which we can't match to a question!"<<endl; 329 335 s_weunmatched++; 330 336 continue; … … 453 459 if((ntohs(pr.d_udp->uh_dport)!=53 && ntohs(pr.d_udp->uh_sport)!=53) || !dh->rd || (unsigned int)pr.d_len <= sizeof(HEADER)) 454 460 return; 455 461 QuestionData qd; 456 462 try { 463 dnsheader* dh=(dnsheader*)pr.d_payload; 464 if(!dh->qr) { 465 qd.d_assignedID = s_idmanager.peakID(); 466 uint16_t tmp=dh->id; 467 dh->id=htons(qd.d_assignedID); 468 s_socket->sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote); 469 dh->id=tmp; 470 } 457 471 MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); 458 472 QuestionIdentifier qi=QuestionIdentifier::create(pr.d_ip, pr.d_udp, mdp); … … 465 479 return; 466 480 } 467 468 481 // new question! 469 470 QuestionData qd;471 482 qd.d_qi=qi; 472 483 gettimeofday(&qd.d_resentTime,0); 473 474 484 qd.d_assignedID = s_idmanager.getID(); 475 476 485 qids.insert(qd); 477 478 dh->id=htons(qd.d_assignedID);479 480 #if 0481 if(lastsent.tv_sec && (!(s_questions%25))) {482 double seconds=pr.d_pheader.ts.tv_sec - lastsent.tv_sec;483 double useconds=(pr.d_pheader.ts.tv_usec - lastsent.tv_usec);484 485 if(useconds < 0) {486 seconds-=1;487 useconds+=1000000;488 }489 490 double factor=10;491 492 seconds/=factor;493 useconds/=factor;494 495 long long nanoseconds=(long long)(1000000000ULL*seconds + useconds * 1000);496 497 struct timespec tosleep;498 tosleep.tv_sec=nanoseconds/1000000000UL;499 tosleep.tv_nsec=nanoseconds%1000000000UL;500 501 nanosleep(&tosleep, 0);502 lastsent=pr.d_pheader.ts;503 }504 if(!lastsent.tv_sec)505 lastsent=pr.d_pheader.ts;506 507 // cout<<"sending!"<<endl;508 #endif509 s_socket->sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);510 486 } 511 487 else { … … 600 576 gettimeofday(&now, 0); 601 577 602 mental_time= mental_time + 3*(now-then);578 mental_time= mental_time + 1*(now-then); 603 579 } 604 580 out:;