Changeset 646
- Timestamp:
- 03/31/06 08:46:58 (6 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 2 modified
-
recursor_cache.cc (modified) (3 diffs)
-
recursor_cache.hh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/recursor_cache.cc
r644 r646 79 79 { 80 80 unsigned int ttd=0; 81 tuple<string, uint16_t> key=make_tuple(toLowerCanonic(qname), qt.getCode()); 82 83 cache_t::const_iterator j=d_cache.find(key); 84 85 // cerr<<"looking up "<< toLowerCanonic(qname)+"|"+qt.getName() << " ("<<key<<", "<<code<<")\n"; 81 string lqname(toLowerCanonic(qname)); 82 83 // cerr<<"looking up "<< toLowerCanonic(qname)+"|"+qt.getName()<<"\n"; 84 85 if(!d_cachecachevalid || d_cachedqname != lqname) { 86 // cerr<<"had cache cache miss"<<endl; 87 d_cachedqname=lqname; 88 d_cachecache=d_cache.equal_range(tie(lqname)); 89 d_cachecachevalid=true; 90 } 91 else 92 ; 93 // cerr<<"had cache cache hit!"<<endl; 94 95 86 96 if(res) 87 97 res->clear(); 88 98 89 if( j!=d_cache.end()) {99 if(d_cachecache.first!=d_cachecache.second) { 90 100 if(res) { 91 for(vector<StoredRecord>::const_iterator k=j->d_records.begin(); k != j->d_records.end(); ++k) { 92 if(k->d_ttd > (uint32_t) now) { 93 DNSResourceRecord rr=String2DNSRR(qname, qt, k->d_string, ttd=k->d_ttd); 94 res->insert(rr); 95 } 96 } 101 for(cache_t::const_iterator i=d_cachecache.first; i != d_cachecache.second; ++i) 102 if(i->d_qtype == qt.getCode()) 103 for(vector<StoredRecord>::const_iterator k=i->d_records.begin(); k != i->d_records.end(); ++k) { 104 if(k->d_ttd > (uint32_t) now) { 105 DNSResourceRecord rr=String2DNSRR(qname, qt, k->d_string, ttd=k->d_ttd); 106 res->insert(rr); 107 } 108 } 97 109 } 98 110 … … 109 121 void MemRecursorCache::replace(const string &qname, const QType& qt, const set<DNSResourceRecord>& content) 110 122 { 123 d_cachecachevalid=false; 111 124 tuple<string, uint16_t> key=make_tuple(toLowerCanonic(qname), qt.getCode()); 112 125 cache_t::iterator stored=d_cache.find(key); … … 180 193 { 181 194 uint32_t now=(uint32_t)time(0); 182 195 d_cachecachevalid=false; 183 196 // cout<<"Going to prune!\n"; 184 197 -
trunk/pdns/pdns/recursor_cache.hh
r623 r646 25 25 { 26 26 public: 27 MemRecursorCache() : d_cachecachevalid(false) 28 {} 27 29 unsigned int size(); 28 30 unsigned int bytes(); … … 107 109 private: 108 110 cache_t d_cache; 109 111 pair<cache_t::const_iterator, cache_t::const_iterator> d_cachecache; 112 string d_cachedqname; 113 bool d_cachecachevalid; 110 114 }; 111 115