Changeset 1262

Show
Ignore:
Timestamp:
08/24/08 18:28:52 (2 years ago)
Author:
ahu
Message:

speed up storing & handling AAAA-records in cache

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/recursor_cache.cc

    r1182 r1262  
    4343  rr.qname=qname; 
    4444 
    45   if(rr.qtype.getCode()==QType::A) { 
     45  if(rr.qtype.getCode()==QType::A && serial.size()==4) { 
    4646    uint32_t ip; 
    4747    memcpy((char*)&ip, serial.c_str(), 4); 
    4848    rr.content=U32ToIP(ntohl(ip)); 
     49  } 
     50  else if(rr.qtype.getCode()==QType::AAAA && serial.size()==16) { 
     51    ComboAddress tmp; 
     52    tmp.sin4.sin_family=AF_INET6; 
     53    memcpy(tmp.sin6.sin6_addr.s6_addr, serial.c_str(), 16); 
     54    rr.content=tmp.toString(); 
    4955  } 
    5056  else if(rr.qtype.getCode()==QType::CNAME || rr.qtype.getCode()==QType::NS || rr.qtype.getCode()==QType::PTR) { 
     
    8591    IpToU32(rr.content, &ip); 
    8692    return string((char*)&ip, 4); 
     93  } 
     94  else if(type==QType::AAAA) { 
     95    ComboAddress ca(rr.content); 
     96    return string((char*)&ca.sin6.sin6_addr.s6_addr, 16); 
    8797  } 
    8898  else if(type==QType::NS || type==QType::CNAME) 
     
    325335    } 
    326336  } 
     337 
    327338  if(isNew) { 
    328339    sort(ce.d_records.begin(), ce.d_records.end()); 
    329340  } 
    330  
     341   
    331342  if(ce.d_records.capacity() != ce.d_records.size()) 
    332343    vector<StoredRecord>(ce.d_records).swap(ce.d_records); 
    333  
     344   
    334345  d_cache.replace(stored, ce); 
    335346}