~ubuntu-branches/ubuntu/maverick/pdns/maverick-updates

« back to all changes in this revision

Viewing changes to pdns/recursor_cache.cc

  • Committer: Bazaar Package Importer
  • Author(s): Debian PowerDNS Maintainers
  • Date: 2005-07-29 20:24:33 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050729202433-cfrk71byx0mmmbk6
Tags: 2.9.18-1
* New upstream release (Closes: #318798)
* Drop patches: 64bit-compile-fix.dpatch, addfeatures-ldapbackend.dpatch,
  amd64-compilefix.dpatch, blankout-domain-fix.dpatch,
  consistent-sql.dpatch, dosfix-ldapbackend.dpatch, fix-exit-status.dpatch,
  gpgsql-compilefix.dpatch, gsqlite-compilefix.dpatch, gsqlite-slave.dpatch,
  recursor-slowdown.patch.dpatch, typoinitscript.dpatch, zone2ldap.dpatch
  They are applied upstream.
* The ldapbackend did not properly escape all queries, allowing it to fail
  and not answer questions. (CAN-2005-2301)
* Questions from clients denied recursion could blank out answers to clients
  who are allowed recursion services, temporarily. (CAN-2005-2302)

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
  return d_cache.size();
10
10
}
11
11
 
12
 
int MemRecursorCache::get(const string &qname, const QType& qt, set<DNSResourceRecord>* res)
 
12
int MemRecursorCache::get(time_t now, const string &qname, const QType& qt, set<DNSResourceRecord>* res)
13
13
{
14
14
  cache_t::const_iterator j=d_cache.find(toLower(qname)+"|"+qt.getName());
15
 
  if(j!=d_cache.end() && j->first==toLower(qname)+"|"+qt.getName() && j->second.begin()->ttl>(unsigned int)time(0)) {
 
15
  if(j!=d_cache.end() && j->first==toLower(qname)+"|"+qt.getName() && j->second.begin()->ttl>(unsigned int)now) {
16
16
    if(res)
17
17
      *res=j->second;
18
18
    
19
 
    return (unsigned int)j->second.begin()->ttl-time(0);
 
19
    return (unsigned int)j->second.begin()->ttl-now;
20
20
  }
21
21
  
22
22
  return -1;
30
30
void MemRecursorCache::doPrune(void)
31
31
{
32
32
  unsigned int names=0, records=0;
33
 
  
 
33
  time_t now=time(0);
34
34
  for(cache_t::iterator j=d_cache.begin();j!=d_cache.end();){
35
35
    for(set<DNSResourceRecord>::iterator k=j->second.begin();k!=j->second.end();) 
36
 
      if((unsigned int)k->ttl < (unsigned int)time(0)) {
 
36
      if((unsigned int)k->ttl < (unsigned int) now) {
37
37
        j->second.erase(k++);
38
38
        records++;
39
39
      }