Changeset 1510
- Timestamp:
- 02/06/10 19:29:45 (3 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 3 modified
-
rec_channel_rec.cc (modified) (2 diffs)
-
recursor_cache.cc (modified) (2 diffs)
-
recursor_cache.hh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/rec_channel_rec.cc
r1496 r1510 111 111 112 112 113 static uint64_t* pleaseDump(int fd) 114 { 115 return new uint64_t(t_RC->doDump(fd)); 116 } 117 113 118 template<typename T> 114 119 string doDumpCache(T begin, T end) … … 123 128 if(fd < 0) 124 129 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"; 129 138 } 130 139 -
trunk/pdns/pdns/recursor_cache.cc
r1507 r1510 328 328 329 329 330 void MemRecursorCache::doDumpAndClose(int fd) 331 { 332 FILE* fp=fdopen(fd, "w"); 333 if(!fp) { 334 close(fd); 335 return; 336 } 337 330 uint64_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"); 338 337 typedef cache_t::nth_index<1>::type sequence_t; 339 338 sequence_t& sidx=d_cache.get<1>(); 340 339 340 uint64_t count=0; 341 341 time_t now=time(0); 342 342 for(sequence_t::const_iterator i=sidx.begin(); i != sidx.end(); ++i) { 343 343 for(vector<StoredRecord>::const_iterator j=i->d_records.begin(); j != i->d_records.end(); ++j) { 344 count++; 344 345 try { 345 346 DNSResourceRecord rr=String2DNSRR(i->d_qname, QType(i->d_qtype), j->d_string, j->d_ttd - now); … … 352 353 } 353 354 fclose(fp); 355 return count; 354 356 } 355 357 -
trunk/pdns/pdns/recursor_cache.hh
r1501 r1510 38 38 void doPrune(void); 39 39 void doSlash(int perc); 40 void doDumpAndClose(int fd);40 uint64_t doDump(int fd); 41 41 int doWipeCache(const string& name, uint16_t qtype=0xffff); 42 42 bool doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL);