Changeset 328 for trunk/pdns/pdns/backends/bind/bindbackend2.cc
- Timestamp:
- 02/23/05 09:13:06 (8 years ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/backends/bind/bindbackend2.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/backends/bind/bindbackend2.cc
r321 r328 647 647 void Bind2Backend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_p, int zoneId ) 648 648 { 649 d_handle =new Bind2Backend::handle;649 d_handle.reset(); // =new Bind2Backend::handle; 650 650 651 651 string domain=toLower(qname); … … 657 657 658 658 if(!s_name_id_map.count(domain)) { 659 // cout<<"no such domain: '"<<qname<<"'"<<endl; 660 d_handle->d_list=false; 661 d_handle->d_bbd=0; 659 d_handle.d_list=false; 660 d_handle.d_bbd=0; 662 661 return; 663 662 } 664 663 unsigned int id=s_name_id_map[domain]; 665 d_handle->id=id; 666 // cout<<"domain: '"<<domain<<"', id="<<id<<endl;667 664 665 d_handle.id=id; 666 668 667 DLOG(L<<"Bind2Backend constructing handle for search for "<<qtype.getName()<<" for "<< 669 668 qname<<endl); 670 671 669 672 670 if(strcasecmp(qname.c_str(),domain.c_str())) 673 d_handle ->qname=toLower(qname.substr(0,qname.size()-domain.length()-1)); // strip domain name674 // cout<<"Reduced to '"<<d_handle->qname<<"'"<<endl;675 d_handle ->parent=this;676 d_handle ->qtype=qtype;677 d_handle ->domain=domain;678 d_handle ->d_records=s_id_zone_map[id]->d_records; // give it a copy679 d_handle ->d_bbd=0;680 if(!d_handle ->d_records->empty()) {671 d_handle.qname=toLower(qname.substr(0,qname.size()-domain.length()-1)); // strip domain name 672 673 d_handle.parent=this; 674 d_handle.qtype=qtype; 675 d_handle.domain=domain; 676 d_handle.d_records=s_id_zone_map[id]->d_records; // give it a copy 677 d_handle.d_bbd=0; 678 if(!d_handle.d_records->empty()) { 681 679 BB2DomainInfo& bbd=*s_id_zone_map[id]; 682 680 if(!bbd.d_loaded) { 683 d elete d_handle;681 d_handle.reset(); 684 682 throw DBException("Zone temporarily not available (file missing, or master dead)"); // fsck 685 683 } … … 687 685 if(!bbd.tryRLock()) { 688 686 L<<Logger::Warning<<"Can't get read lock on zone '"<<bbd.d_name<<"'"<<endl; 689 d elete d_handle;687 d_handle.reset(); 690 688 throw DBException("Temporarily unavailable due to a zone lock"); // fsck 691 689 } … … 695 693 queueReload(&bbd); 696 694 } 697 d_handle ->d_bbd=&bbd;695 d_handle.d_bbd=&bbd; 698 696 } 699 697 else { … … 703 701 pair<vector<Bind2DNSRecord>::const_iterator, vector<Bind2DNSRecord>::const_iterator> range; 704 702 705 // cout<<"starting equal range for: '"<<d_handle ->qname<<"'"<<endl;706 range=equal_range(d_handle ->d_records->begin(), d_handle->d_records->end(), d_handle->qname);703 // cout<<"starting equal range for: '"<<d_handle.qname<<"'"<<endl; 704 range=equal_range(d_handle.d_records->begin(), d_handle.d_records->end(), d_handle.qname); 707 705 708 706 if(range.first==range.second) { 709 d_handle ->d_bbd=0;710 d_handle ->d_list=false;707 d_handle.d_bbd=0; 708 d_handle.d_list=false; 711 709 return; 712 710 } 713 711 else { 714 d_handle ->d_iter=range.first;715 d_handle ->d_end_iter=range.second;716 } 717 718 d_handle ->d_list=false;712 d_handle.d_iter=range.first; 713 d_handle.d_end_iter=range.second; 714 } 715 716 d_handle.d_list=false; 719 717 } 720 718 … … 728 726 bool Bind2Backend::get(DNSResourceRecord &r) 729 727 { 730 if(!d_handle ->d_records)728 if(!d_handle.d_records) 731 729 return false; 732 730 733 if(!d_handle->get(r)) { 734 delete d_handle; 735 d_handle=0; 731 if(!d_handle.get(r)) { 732 d_handle.reset(); 736 733 737 734 if(arg().mustDo("query-logging")) … … 793 790 bool Bind2Backend::list(const string &target, int id) 794 791 { 795 // cout<<"List of id "<<id<<" requested"<<endl;796 792 if(!s_id_zone_map.count(id)) 797 793 return false; 798 794 799 d_handle =new Bind2Backend::handle;795 d_handle.reset(); // new Bind2Backend::handle; 800 796 DLOG(L<<"Bind2Backend constructing handle for list of "<<id<<endl); 801 797 802 d_handle->d_qname_iter=s_id_zone_map[id]->d_records->begin(); 803 d_handle->d_qname_end=s_id_zone_map[id]->d_records->end(); // iter now points to a vector of pointers to vector<BBResourceRecords> 804 805 d_handle->parent=this; 806 d_handle->id=id; 807 d_handle->d_list=true; 798 d_handle.d_qname_iter=s_id_zone_map[id]->d_records->begin(); 799 d_handle.d_qname_end=s_id_zone_map[id]->d_records->end(); // iter now points to a vector of pointers to vector<BBResourceRecords> 800 801 d_handle.d_records=s_id_zone_map[id]->d_records; // give it a copy --- WHY??? XXX FIXME 802 803 d_handle.parent=this; 804 d_handle.id=id; 805 d_handle.d_list=true; 808 806 return true; 809 807 … … 813 811 { 814 812 if(d_qname_iter!=d_qname_end) { 815 // r=*d_qname_iter; // XXX FIXME WRONG WRONG WRONG 813 r.qname=d_qname_iter->qname.empty() ? domain : (d_qname_iter->qname+"."+domain); 814 r.domain_id=id; 815 r.content=(d_qname_iter)->content; 816 r.qtype=(d_qname_iter)->qtype; 817 r.ttl=(d_qname_iter)->ttl; 816 818 d_qname_iter++; 817 819 return true;