Changeset 1510

Show
Ignore:
Timestamp:
02/06/10 19:29:45 (3 years ago)
Author:
ahu
Message:

fix dump-cache for the new pimped world

Location:
trunk/pdns/pdns
Files:
3 modified

Legend:

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

    r1496 r1510  
    111111 
    112112 
     113static uint64_t* pleaseDump(int fd) 
     114{ 
     115  return new uint64_t(t_RC->doDump(fd)); 
     116} 
     117 
    113118template<typename T> 
    114119string doDumpCache(T begin, T end) 
     
    123128  if(fd < 0)  
    124129    return "Error opening dump file for writing: "+string(strerror(errno))+"\n"; 
    125  
    126   t_RC->doDumpAndClose(fd); // RC MULTI FIXME 
    127  
    128   return "done\n"; 
     130  uint64_t total = 0; 
     131  try { 
     132    total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDump, fd)); 
     133  } 
     134  catch(...){} 
     135   
     136  close(fd); 
     137  return "dumped "+lexical_cast<string>(total)+" records\n"; 
    129138} 
    130139 
  • trunk/pdns/pdns/recursor_cache.cc

    r1507 r1510  
    328328 
    329329 
    330 void MemRecursorCache::doDumpAndClose(int fd) 
    331 { 
    332   FILE* fp=fdopen(fd, "w"); 
    333   if(!fp) { 
    334     close(fd); 
    335     return; 
    336   } 
    337  
     330uint64_t MemRecursorCache::doDump(int fd) 
     331{ 
     332  FILE* fp=fdopen(dup(fd), "w"); 
     333  if(!fp) { // dup probably failed 
     334    return 0; 
     335  } 
     336  fprintf(fp, "; dump from thread follows\n;\n"); 
    338337  typedef cache_t::nth_index<1>::type sequence_t; 
    339338  sequence_t& sidx=d_cache.get<1>(); 
    340339 
     340  uint64_t count=0; 
    341341  time_t now=time(0); 
    342342  for(sequence_t::const_iterator i=sidx.begin(); i != sidx.end(); ++i) { 
    343343    for(vector<StoredRecord>::const_iterator j=i->d_records.begin(); j != i->d_records.end(); ++j) { 
     344      count++; 
    344345      try { 
    345346        DNSResourceRecord rr=String2DNSRR(i->d_qname, QType(i->d_qtype), j->d_string, j->d_ttd - now); 
     
    352353  } 
    353354  fclose(fp); 
     355  return count; 
    354356} 
    355357 
  • trunk/pdns/pdns/recursor_cache.hh

    r1501 r1510  
    3838  void doPrune(void); 
    3939  void doSlash(int perc); 
    40   void doDumpAndClose(int fd); 
     40  uint64_t doDump(int fd); 
    4141  int doWipeCache(const string& name, uint16_t qtype=0xffff); 
    4242  bool doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL);