Changeset 628
- Timestamp:
- 03/26/06 12:51:55 (7 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 5 modified
-
mtasker.cc (modified) (1 diff)
-
pdns_recursor.cc (modified) (2 diffs)
-
rec_channel_rec.cc (modified) (2 diffs)
-
syncres.cc (modified) (4 diffs)
-
syncres.hh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/mtasker.cc
r596 r628 1 1 /* 2 2 PowerDNS Versatile Database Driven Nameserver 3 Copyright (C) 2002 - 200 5PowerDNS.COM BV3 Copyright (C) 2002 - 2006 PowerDNS.COM BV 4 4 5 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 6 it under the terms of the GNU General Public License version 2 as 7 published by the Free Software Foundation 9 8 10 9 This program is distributed in the hope that it will be useful, -
trunk/pdns/pdns/pdns_recursor.cc
r627 r628 49 49 #include "rec_channel.hh" 50 50 51 //using namespace boost;51 using namespace boost; 52 52 53 53 #ifdef __FreeBSD__ // see cvstrac ticket #26 … … 546 546 RC.doPrune(); 547 547 int pruned=0; 548 for(SyncRes::negcache_t::iterator i = SyncRes::s_negcache.begin(); i != SyncRes::s_negcache.end();) 549 if(i->second.ttd < now.tv_sec) { 550 SyncRes::s_negcache.erase(i++); 551 pruned++; 552 } 553 else 554 ++i; 548 549 typedef SyncRes::negcache_t::nth_index<1>::type negcache_by_ttd_index_t; 550 negcache_by_ttd_index_t& ttdindex=boost::multi_index::get<1>(SyncRes::s_negcache); 551 552 negcache_by_ttd_index_t::iterator i=ttdindex.lower_bound(now.tv_sec); 553 ttdindex.erase(ttdindex.begin(), i); 555 554 556 555 time_t limit=now.tv_sec-300; -
trunk/pdns/pdns/rec_channel_rec.cc
r625 r628 112 112 addGetStat("cache-misses", &RC.cacheMisses); 113 113 114 addGetStat("cache-entries", b ind(&MemRecursorCache::size, ref(RC)));114 addGetStat("cache-entries", boost::bind(&MemRecursorCache::size, ref(RC))); 115 115 addGetStat("servfail-answers", &g_stats.servFails); 116 116 addGetStat("nxdomain-answers", &g_stats.nxDomains); … … 126 126 127 127 addGetStat("all-questions", &qcounter); 128 addGetStat("negcache-entries", b ind(&SyncRes::negcache_t::size, ref(SyncRes::s_negcache)));129 addGetStat("throttle-entries", b ind(&SyncRes::throttle_t::size, ref(SyncRes::s_throttle)));130 addGetStat("nsspeeds-entries", b ind(&SyncRes::nsspeeds_t::size, ref(SyncRes::s_nsSpeeds)));128 addGetStat("negcache-entries", boost::bind(&SyncRes::negcache_t::size, ref(SyncRes::s_negcache))); 129 addGetStat("throttle-entries", boost::bind(&SyncRes::throttle_t::size, ref(SyncRes::s_throttle))); 130 addGetStat("nsspeeds-entries", boost::bind(&SyncRes::nsspeeds_t::size, ref(SyncRes::s_nsSpeeds))); 131 131 132 addGetStat("concurrent-queries", b ind(&MTasker<PacketID,string>::numProcesses, ref(MT)));132 addGetStat("concurrent-queries", boost::bind(&MTasker<PacketID,string>::numProcesses, ref(MT))); 133 133 addGetStat("outgoing-timeouts", &SyncRes::s_outgoingtimeouts); 134 134 addGetStat("tcp-outqueries", &SyncRes::s_tcpoutqueries); -
trunk/pdns/pdns/syncres.cc
r624 r628 249 249 uint32_t sttl=0; 250 250 251 if(s_negcache.count(toLower(qname))) { 251 negcache_t::iterator ni=s_negcache.find(toLower(qname)); 252 if(ni!=s_negcache.end()) { 253 cerr<<"found something\n"; 252 254 res=0; 253 negcache_t::const_iterator ni=s_negcache.find(toLower(qname)); 254 if(d_now.tv_sec < ni->second.ttd) { 255 sttl=ni->second.ttd - d_now.tv_sec; 255 if((uint32_t)d_now.tv_sec < ni->d_ttd) { 256 sttl=ni->d_ttd - d_now.tv_sec; 256 257 LOG<<prefix<<qname<<": Entire record '"<<toLower(qname)<<"', is negatively cached for another "<<sttl<<" seconds"<<endl; 257 258 res=RCode::NXDomain; 258 259 giveNegative=true; 259 sqname=ni-> second.name;260 sqname=ni->d_qname; 260 261 sqt="SOA"; 261 262 } 262 263 else { 263 264 LOG<<prefix<<qname<<": Entire record '"<<toLower(qname)<<"' was negatively cached, but entry expired"<<endl; 264 s_negcache.erase( toLower(qname));265 s_negcache.erase(ni); 265 266 } 266 267 } … … 271 272 272 273 res=0; 273 n egcache_t::const_iterator ni=s_negcache.find(tuple);274 ni=s_negcache.find(tuple); 274 275 if(ni!=s_negcache.end()) { 275 if( d_now.tv_sec < ni->second.ttd) {276 sttl=ni-> second.ttd - d_now.tv_sec;276 if((uint32_t)d_now.tv_sec < ni->d_ttd) { 277 sttl=ni->d_ttd - d_now.tv_sec; 277 278 LOG<<prefix<<qname<<": "<<qtype.getName()<<" is negatively cached for another "<<sttl<<" seconds"<<endl; 278 279 res=RCode::NoError; // only this record doesn't exist 279 280 giveNegative=true; 280 sqname=ni-> second.name;281 sqname=ni->d_qname; 281 282 sqt="SOA"; 282 283 } 283 284 else { 284 285 LOG<<prefix<<qname<<": "<<qtype.getName()<<" was negatively cached, but entry expired"<<endl; 285 s_negcache.erase( toLower(tuple));286 s_negcache.erase(ni); 286 287 } 287 288 } … … 529 530 530 531 NegCacheEntry ne; 531 ne.name=i->qname; 532 ne.ttd=d_now.tv_sec + i->ttl; 533 s_negcache[toLower(qname)]=ne; 532 533 ne.d_qname=i->qname; 534 ne.d_ttd=d_now.tv_sec + min(i->ttl, 3600U); // controversial 535 ne.d_name=toLower(qname); 536 s_negcache.insert(ne); 534 537 negindic=true; 535 538 } … … 568 571 569 572 NegCacheEntry ne; 570 ne.name=i->qname; 571 ne.ttd=d_now.tv_sec + i->ttl; 572 s_negcache[toLower(qname)+"|"+qtype.getName()]=ne; 573 ne.d_qname=i->qname; 574 ne.d_ttd=d_now.tv_sec + min(3600U,i->ttl); 575 ne.d_name=toLower(qname)+"|"+qtype.getName(); 576 s_negcache.insert(ne); 573 577 negindic=true; 574 578 } -
trunk/pdns/pdns/syncres.hh
r619 r628 26 26 struct NegCacheEntry 27 27 { 28 string name; 29 time_t ttd; 28 string d_qname; 29 string d_name; 30 uint32_t d_ttd; 30 31 }; 31 32 … … 241 242 unsigned int d_throttledqueries; 242 243 unsigned int d_timeouts; 243 typedef map<string,NegCacheEntry> negcache_t; 244 // typedef map<string,NegCacheEntry> negcache_t; 245 246 typedef multi_index_container < 247 NegCacheEntry, 248 indexed_by < 249 ordered_unique< 250 member<NegCacheEntry, string, &NegCacheEntry::d_name> 251 >, 252 ordered_non_unique< 253 member<NegCacheEntry, uint32_t, &NegCacheEntry::d_ttd> 254 > 255 > 256 >negcache_t; 244 257 static negcache_t s_negcache; 245 258