Changeset 1484
- Timestamp:
- 01/02/10 20:30:14 (8 months ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 2 modified
-
recursor_cache.cc (modified) (10 diffs)
-
recursor_cache.hh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/recursor_cache.cc
r1472 r1484 6 6 #include "arguments.hh" 7 7 #include "syncres.hh" 8 #include "lock.hh"9 8 #include "recursor_cache.hh" 10 9 … … 106 105 { 107 106 unsigned int ttd=0; 108 { 109 WriteLock wl(&d_rwlock); 110 // cerr<<"looking up "<< qname+"|"+qt.getName()<<"\n"; 111 112 if(!d_cachecachevalid || !pdns_iequals(d_cachedqname, qname)) { 113 // cerr<<"had cache cache miss"<<endl; 114 d_cachedqname=qname; 115 d_cachecache=d_cache.equal_range(tie(qname)); 116 d_cachecachevalid=true; 117 } 118 else 119 // cerr<<"had cache cache hit!"<<endl; 120 ; 121 } 122 ReadLock l(&d_rwlock); 107 // cerr<<"looking up "<< qname+"|"+qt.getName()<<"\n"; 108 109 if(!d_cachecachevalid || !pdns_iequals(d_cachedqname, qname)) { 110 // cerr<<"had cache cache miss"<<endl; 111 d_cachedqname=qname; 112 d_cachecache=d_cache.equal_range(tie(qname)); 113 d_cachecachevalid=true; 114 } 115 else 116 // cerr<<"had cache cache hit!"<<endl; 117 ; 123 118 124 119 if(res) … … 131 126 ) { 132 127 typedef cache_t::nth_index<1>::type sequence_t; 133 //sequence_t& sidx=d_cache.get<1>();128 sequence_t& sidx=d_cache.get<1>(); 134 129 sequence_t::iterator si=d_cache.project<1>(i); 135 130 … … 144 139 } 145 140 if(res) { 146 147 148 #if 0 // XXX FIXME removed because of threading - sidx should not be touched holding just a readlock!149 141 if(res->empty()) 150 142 sidx.relocate(sidx.begin(), si); 151 143 else 152 144 sidx.relocate(sidx.end(), si); 153 #endif154 145 } 155 146 if(qt.getCode()!=QType::ANY && qt.getCode()!=QType::ADDR) // normally if we have a hit, we are done … … 167 158 bool MemRecursorCache::attemptToRefreshNSTTL(const QType& qt, const set<DNSResourceRecord>& content, const CacheEntry& stored) 168 159 { 169 // WriteLock wl(&d_rwlock); (holds the lock already)170 160 if(!stored.d_auth) { 171 161 // cerr<<"feel free to scribble non-auth data!"<<endl; … … 199 189 void MemRecursorCache::replace(time_t now, const string &qname, const QType& qt, const set<DNSResourceRecord>& content, bool auth) 200 190 { 201 WriteLock wl(&d_rwlock);202 191 d_cachecachevalid=false; 203 192 tuple<string, uint16_t> key=make_tuple(qname, qt.getCode()); … … 296 285 int MemRecursorCache::doWipeCache(const string& name, uint16_t qtype) 297 286 { 298 WriteLock wl(&d_rwlock);299 287 int count=0; 300 288 d_cachecachevalid=false; … … 314 302 bool MemRecursorCache::doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL) 315 303 { 316 WriteLock wl(&d_rwlock);317 304 cache_t::iterator iter = d_cache.find(tie(name, qtype)); 318 305 if(iter == d_cache.end()) … … 343 330 void MemRecursorCache::doDumpAndClose(int fd) 344 331 { 345 WriteLock wl(&d_rwlock);346 332 FILE* fp=fdopen(fd, "w"); 347 333 if(!fp) { … … 375 361 void MemRecursorCache::doPrune(void) 376 362 { 377 WriteLock wl(&d_rwlock);378 363 uint32_t now=(uint32_t)time(0); 379 364 d_cachecachevalid=false; -
trunk/pdns/pdns/recursor_cache.hh
r1472 r1484 29 29 MemRecursorCache() : d_followRFC2181(false), d_cachecachevalid(false) 30 30 { 31 pthread_rwlock_init(&d_rwlock, 0); 32 // cerr<<"ce: "<<sizeof(CacheEntry)<<", sr: "<<sizeof(struct StoredRecord)<<endl; 31 cacheHits = cacheMisses = 0; 33 32 } 34 33 unsigned int size(); … … 110 109 bool d_cachecachevalid; 111 110 bool attemptToRefreshNSTTL(const QType& qt, const set<DNSResourceRecord>& content, const CacheEntry& stored); 112 113 pthread_rwlock_t d_rwlock;114 // boost::shared_mutex d_smutex;115 111 }; 116 112 string DNSRR2String(const DNSResourceRecord& rr);