Changeset 319 for trunk/pdns/pdns/backends/bind/bindbackend2.cc
- Timestamp:
- 02/13/05 21:56:57 (8 years ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/backends/bind/bindbackend2.cc (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/backends/bind/bindbackend2.cc
r193 r319 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2002-200 3PowerDNS.COM BV3 Copyright (C) 2002-2005 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 16 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 */ 18 // $Id: bindbackend2.cc,v 1.6 2003/10/04 14:15:46 ahu Exp $ 18 19 19 #include <errno.h> 20 20 #include <string> … … 47 47 /** new scheme of things: 48 48 we have zone-id map 49 a zone-id has a vector of DNSResourceRecords */ 49 a zone-id has a vector of DNSResourceRecords 50 on start of query, we find the best zone to answer from 51 52 handle::get walks this vector linearly... */ 50 53 51 54 map<string,int> Bind2Backend::s_name_id_map; … … 115 118 bool Bind2Backend::startTransaction(const string &qname, int id) 116 119 { 117 118 120 BB2DomainInfo &bbd=*s_id_zone_map[d_transaction_id=id]; 119 121 d_transaction_tmpname=bbd.d_filename+"."+itoa(random()); … … 171 173 string content=r.content; 172 174 173 // SOA needs stripping too! XXX FIXME 175 // SOA needs stripping too! XXX FIXME - also, this should not be here I think 174 176 switch(r.qtype.getCode()) { 175 177 case QType::TXT: … … 283 285 i!=ret.end(); 284 286 ++i) 285 ; // *i=*i; //tolower(*i);287 *i=tolower(*i); 286 288 287 289 … … 299 301 rr.qname=canonic(qnameu); 300 302 rr.qtype=qtype; 301 rr.content=c ontent;303 rr.content=canonic(content); // I think this is wrong, the zoneparser should not come up with . terminated stuff XXX FIXME 302 304 rr.ttl=ttl; 303 305 rr.priority=prio; … … 384 386 } 385 387 386 387 388 388 Bind2Backend::Bind2Backend(const string &suffix) 389 389 { … … 427 427 428 428 loadConfig(); 429 430 429 431 430 extern DynListener *dl; … … 587 586 Does not throw errors or anything, may update d_status however */ 588 587 589 590 588 void Bind2Backend::queueReload(BB2DomainInfo *bbd) 591 589 { … … 626 624 { 627 625 d_handle=new Bind2Backend::handle; 628 d_handle->d_records=new vector<DNSResourceRecord>; // WRONG 629 // cout<<"Lookup! for "<<qname<<endl; 630 string domain=qname; 626 627 string domain=toLower(qname); 628 629 if(arg().mustDo("query-logging")) 630 L<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"'"<<endl; 631 631 632 while(!s_name_id_map.count(domain) && chopOff(domain)); 632 633 633 634 if(!s_name_id_map.count(domain)) { 634 635 // cout<<"no such domain: '"<<qname<<"'"<<endl; 635 d_handle->d_iter=d_handle->d_records->end(); // WRONG636 636 d_handle->d_list=false; 637 637 d_handle->d_bbd=0; … … 641 641 642 642 // cout<<"domain: '"<<domain<<"', id="<<id<<endl; 643 644 643 645 644 DLOG(L<<"Bind2Backend constructing handle for search for "<<qtype.getName()<<" for "<< … … 649 648 d_handle->parent=this; 650 649 d_handle->qtype=qtype; 651 string compressed=toLower(qname); 652 d_handle->d_records=s_id_zone_map[id]->d_records; 650 651 d_handle->d_records=s_id_zone_map[id]->d_records; // give it a copy 653 652 d_handle->d_bbd=0; 654 653 if(!d_handle->d_records->empty()) { … … 656 655 if(!bbd.d_loaded) { 657 656 delete d_handle; 658 throw DBException("Zone temporarily not available (file missing, or master dead)"); // f uck657 throw DBException("Zone temporarily not available (file missing, or master dead)"); // fsck 659 658 } 660 659 … … 662 661 L<<Logger::Warning<<"Can't get read lock on zone '"<<bbd.d_name<<"'"<<endl; 663 662 delete d_handle; 664 throw DBException("Temporarily unavailable due to a zone lock"); // fuck 665 } 666 667 663 throw DBException("Temporarily unavailable due to a zone lock"); // fsck 664 } 665 668 666 if(!bbd.current()) { 669 667 L<<Logger::Warning<<"Zone '"<<bbd.d_name<<"' ("<<bbd.d_filename<<") needs reloading"<<endl; … … 682 680 { 683 681 d_bbd=0; 682 d_records=0; 684 683 count=0; 685 684 } … … 687 686 bool Bind2Backend::get(DNSResourceRecord &r) 688 687 { 688 if(!d_handle->d_records) 689 return false; 690 689 691 if(!d_handle->get(r)) { 690 692 delete d_handle; 691 693 d_handle=0; 694 695 if(arg().mustDo("query-logging")) 696 L<<"End of answers"<<endl; 697 692 698 return false; 693 699 } 700 if(arg().mustDo("query-logging")) 701 L<<"Returning: '"<<r.qtype.getName()<<"' of '"<<r.qname<<"', content: '"<<r.content<<"'"<<endl; 694 702 return true; 695 703 } … … 708 716 qname<<"- "<<d_records->size()<<" available!"<<endl); 709 717 710 while(d_iter!=d_records->end() && (d_iter->qname!=qname || !(qtype=="ANY" || (d_iter)->qtype==qtype))) { 718 // this is a linear walk!!! XXX FIXME 719 while(d_iter!=d_records->end() && (strcasecmp(d_iter->qname.c_str(),qname.c_str()) || !(qtype=="ANY" || (d_iter)->qtype==qtype))) { 711 720 DLOG(L<<Logger::Warning<<"Skipped "<<qname<<"/"<<QType(d_iter->qtype).getName()<<": '"<<d_iter->content<<"'"<<endl); 712 721 d_iter++; … … 721 730 DLOG(L << "Bind2Backend get() returning a rr with a "<<QType(d_iter->qtype).getCode()<<endl); 722 731 723 r.qname=qname; // fill this in732 r.qname=qname; 724 733 725 734 r.content=(d_iter)->content;